Skip to content
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

Closed
motohead400 opened this issue Nov 7, 2019 — with docs.microsoft.com · 7 comments · Fixed by #15581 or #15960
Closed

UseStaticFiles still needed with UseFileServer for wwwroot #15578

motohead400 opened this issue Nov 7, 2019 — with docs.microsoft.com · 7 comments · Fixed by #15581 or #15960
Assignees
Labels
doc-bug Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

Copy link

motohead400 commented Nov 7, 2019

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.

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels Nov 7, 2019
@Rick-Anderson Rick-Anderson self-assigned this Nov 7, 2019
@Rick-Anderson Rick-Anderson added this to To do in November 2019 via automation Nov 7, 2019
@Rick-Anderson
Copy link
Contributor

That's not correct. See https://stackoverflow.com/a/50381816/502537

November 2019 automation moved this from To do to Done Nov 7, 2019
@motohead400
Copy link
Author

I understand that's what it's SUPPOSED to do. I read the documentation, as was obvious in my post. However that is NOT the behavior I experienced. Without app.UseStaticFiles() in my code below, static files in the wwwroot do not get served. Maybe it has something to do with me adding an additional file provider?
image

@Rick-Anderson
Copy link
Contributor

If you check the source you'll see it calls UseStaticFiles

@Rick-Anderson
Copy link
Contributor

Try to repo the problem without the file provider.

@motohead400
Copy link
Author

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.

@Rick-Anderson Rick-Anderson reopened this Nov 7, 2019
November 2019 automation moved this from Done to In progress Nov 7, 2019
@Rick-Anderson
Copy link
Contributor

@Tratcher is this expected? SHould we document this?

@Tratcher
Copy link
Member

Tratcher commented Nov 7, 2019

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.

@Rick-Anderson Rick-Anderson removed this from In progress in November 2019 Dec 3, 2019
@Rick-Anderson Rick-Anderson added this to To do in December 2019 via automation Dec 3, 2019
December 2019 automation moved this from To do to Done Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-bug Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
No open projects
December 2019
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants