Skip to content

UseStaticFiles should display the default PhysicalFileProvider default path when using a constructor that doesn't override the default IFileProvider #38481

@MaximRouiller

Description

@MaximRouiller

Is your feature request related to a problem? Please describe.

This request is related to a discoverability issue for UseStaticFiles extension. If do not start from a default template and add UseStaticFiles(), the inline xmldoc do not describe the default local physical path it will try to fetch the static files from.

  • Running dotnet run does not log the issue in the console that no path /wwwroot exist in the project and that UseStaticFiles will do nothing.
  • Creating a static file at the root and trying to match the url and the physical path only returns a 404 without any more help.

image

Describe the solution you'd like

Default values like /wwwroot for static files should be document in the xmldoc of the API at the point of calling as to help people avoid having to switch context between their code and the docs.

Additionally, calling the extension UseStaticFiles while the default physical path /wwwroot doesn't exist should create an warning message in the logs to warn the developer of a misconfiguration. If implemented, this message should only be shown once as to avoid polluting the logs.

Additional context

My context here is for new adopter of .NET that are simply trying to create a simple API. It should be easy for them to create code without relying on the docs unless they are stuck.

Metadata

Metadata

Assignees

Labels

DocsThis issue tracks updating documentationarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionshelp wantedUp for grabs. We would accept a PR to help resolve this issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions