-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UseStaticFiles still needed with UseFileServer for wwwroot #15578
UseStaticFiles still needed with UseFileServer for wwwroot #15578
Comments
That's not correct. See https://stackoverflow.com/a/50381816/502537 |
If you check the source you'll see it calls |
Try to repo the problem without the file provider. |
I did as you suggested and if I just call app.UseFileServer() without passing the FileServerOptions into it I'm able to remove the call to app.UseStaticFiles() and still have files served from the wwwroot directory as would be expected. So there seems to be a bug with using a file provider causing UseFileServer() to not allow files from the wwwroot directory to be served. |
@Tratcher is this expected? SHould we document this? |
Yes, that's expected. UseStaticFiles/UseFileServer defaults to the file provider pointing at wwwroot. You can provide additional instances of UseStaticFiles/UseFileServer with other file providers to serve files from other locations. |
The documentation says UseFileServer is like calling UseStaticFiles, UseDefaultFiles, and UseDirectoryBrowser. This is not the behavior I encountered with .net core 2.2 (Web API application). I had to add a call to
UseStaticFiles
in order for files to be served from the wwwroot directory. I wasted over an hour on this.Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: