-
Notifications
You must be signed in to change notification settings - Fork 72
Static files returning 404 #65
Comments
Can you push your repro app to github so we can clone and try it? |
Here is a sample repo: https://github.com/csunali/StaticFiles404 Clear steps to reproduce the issue are below. Working scenario:
Non-working scenario 1:
Non-working scenario 2:
As you can see, you don't need to hit an embedded file initially in order to break the functionality. Hitting even a physically existing file (jquery.js in this case) breaks it. What I understand is that, as long as you hit a static file first, the custom file provider breaks for the rest of the process until you restart the web server. If you hit a regular MVC controller first, everything keeps working. I have also seen times when the static file provider broke later on, after some amount of time. That happened under IIS. I found an issue regarding that but it was not of any help as it was closed without any action being taken. That issue can be found at #59. |
Repro'd. This is an IIS/Express integration bug, not a bug with the static file middleware. It does not repro with WebListener. Here's what I think is happing:
B) Broken scenario:
#59 could also be caused by this because IIS can shut down your application if it does not receive any requests for a given period of time. Then when the next request arrives your back in the initial boot up mode. We need to verify if this also happens in full IIS. |
Some additional details:
Workaround: Add the following to your web.config after publishing
|
Glad you were able to repro. Should I take any additional actions on this matter or you will take care of the rest? I mean, shall I create an additional issue on another repo where it suits better for IIS integration issues? If so, where? |
Thank you for the workaround by the way. |
We'll take care of it, thanks. |
This issue was moved to aspnet/Helios#188 |
Here is the scenario;
StaticFiles
middleware.StaticFiles
hasStaticFilesOptions
whereFileProvider
property is set to a custom provider (EmbeddedFileProvider
).EmbeddedFileProvider
accepts aPhysicalFileProvider
instance which is used to check if the file physically exists. If it does,EmbeddedFileProvider
just uses thePhysicalFileProvider
to return the requested file, otherwise it checks embedded resources.HomeController
), Startup methods get called without any issues, etc.HomeController
(/Home
) but instead, make a request to a static file (that can be either a physical file or an embedded file, does not matter at all). If it is a physical file, the file returns correctly. If it is an embedded file, it returns 404 already. Either case breaks the rest of the process.HomeController
which has references to static files using<script>
tags for Javascript files and<link>
tags for stylesheet files. The Home view returns correctly but none of the static files do. They return 404 instead.The text was updated successfully, but these errors were encountered: