I have an ASP.NET MVC application that is hosted on Windows Azure and all the static files served from the website are being processed by ASP.NET. Is there a way to get IIS to serve the static files directly and not route those requests through ASP.NET? I'm looking to help improve the performance of returning those static files from the server.
I'm not sure if this is something that ASP.NET MVC itself does, or if it's because of the fact that I'm hosting it on Azure.
UPDATE: The main reason I'm looking to do this is because the static files are processed by all HttpModules registered in the application, thus slowing performance some.
To serve static files from an ASP.NET Core app, you must configure static files middleware. With static files middleware configured, an ASP.NET Core app will serve all files located in a certain folder (typically /wwwroot).
Static files are stored within the project's web root directory. The default directory is {content root}/wwwroot , but it can be changed with the UseWebRoot method. For more information, see Content root and Web root. The preceding code was created with the web app template.
ASP.NET Core can serve static files—HTML files, images, JavaScript files, etc. —directly to clients. To enable ASP.NET Core to serve static files, you must use the framework's Static Files Middleware in your application, and you must specify the necessary configuration.
ASP.NET MVC 5 for Beginners Static files like JavaScript files, images, CSS files that we have on the file system are the assets that ASP.NET Core application can serve directly to clients. Static files are typically located in the web root (wwwroot) folder.
I removed the "runAllManagedModulesForAllRequests='true'" definition in the web.config and added "preCondition='managedHandler" to the HttpModule registrations that I don't want to execute for static content.
I also implemented Darin's answer.
Not entirely what I was looking for, but it seems to fit the bill.
UPDATE: if you remove "runAllManagedModulesForAllRequests=true" from web.config, make sure your IIS is up to date, otherwise extensionless URIs won't work anymore. KB about that: http://support.microsoft.com/kb/980368/en-us
(Of course, even if you keep that option, your should worry about your server being up to date.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With