开发者

ASP.NET MVC: The HttpApplication processes every request to the server including requests for css, js, img. Is it normal?

开发者 https://www.devze.com 2023-03-06 17:02 出处:网络
There is a heavy mvc application and many styles, scipts, images into the every page. But the HttpApplication processes an every request to the server including requests for .css, js, img. I assume it

There is a heavy mvc application and many styles, scipts, images into the every page. But the HttpApplication processes an every request to the server including requests for .css, js, img. I assume it spends resources.

开发者_开发问答

Can I turn off that?


Some of the other responses are a bit misleading so I'll chime in.

The setting that controls this behavior is the runAllManagedModulesForAllRequests attribute located in the configuration\system.webServer\modules section of your Web.config file. Every MVC project template has that set to true by default. You could set it to false to disable the behavior.

However, note that this might cause your routes to stop working. That's because on earlier versions of IIS this setting was required to make routing work with extenionless URLs. Without this setting IIS used to treat such requests as if they referred to folders and would bypass the managed pipeline altogether. This setting forces IIS to run all managed modules for all requests (as the name of the setting eloquently implies), thus giving URL routing a chance to respond.

In Windows Server 2008 R2 SP1 (or other OS's that have KB980368 installed) this setting is no longer necessary.

So depending on the configuration of your servers you might be able to turn it off, but you should certainly test first to verify your application will continue to work.


The resources need to be spent, or else IIS will not be able to send these files to the browser.

Requests to static files do not go through the dynamic request pipeline - they are bypassed, so shouldn't be a concern in this respect.


If you are in a position to have legitimate concerns about the consumption of server hardware resources used to serve resource files on your application, the solution to that is to remove those resources from your application.

That is the entire purpose of a content distribution network.

0

精彩评论

暂无评论...
验证码 换一张
取 消