Thursday, June 21, 2012

Optimize the performance of your web applications: Don’t use runAllManagedModulesForAllRequests="true”.

In a lot of web applications I’ve seen (and created myself), the runAllManagedModulesForAllRequests is set to true inside the web.config. In a lot of articles, blog posts and so on… this is mentioned as a good idea. It’s even a default when you create a new ASP. NET MVC application.  However last week I was listening to a Hanselminutes podcast with Nathanael Jones where they said that this was really a bad idea and had a negative impact on the overall performance of your web application.
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>

Running these modules for all your dynamic content is fine. However doing the same thing for all your static content  is pure overhead and offers no benefits. All your registered HTTP modules run on every request, not just managed requests (e.g. .aspx). This means modules will run on every .jpg, .gif, .css, .html, .pdf etc. 
How can we fix this?
In fact if you are using IIS 7.5 there is not much you need to do, just remove the modules section and you are done.

Remark: Some people on StackOverflow mentioned they had errors after removing this section, in that case I suggest installing the following update:


Dave Van den Eynde said...
This comment has been removed by the author.
Dave Van den Eynde said...

Your static stuff should not be hosted from IIS anyway. Either use CDN or a secondary web server/farm using a more suitable web server like nginx or lighttpd.

Sameer Alibhai said...

Great idea. thanks

Bangalore Web Guru said...

Such a very nice blog. Really i learn so much things in your blog. Thanks for sharing Web Development Company Bangalore | Website Development Company Bangalore

Imran Hashmi said...
This comment has been removed by a blog administrator.
naveed hussain said...

great work KMS Activator
cubase Crack

atifabushra said...

Nice article for readers