R – IIS7 Integrated Mode – Bypass Forms Auth for static files

asp.netasp.net-mvcforms-authenticationiis-7

I have a ASP.NET MVC app on IIS7 using Forms Authentication in Integrated Mode. I am noticing that the ASP.NET runtime is being hit for every request that comes in even if it is only for static files (probably because of Integrated Mode). Is there a way to configure IIS7 to serve up static files without hitting ASP.NET?

I've been thinking that the only way around this is to create a separate virtual directory just for static files — a mini-CDN, if you will.

Any other ideas?

Best Answer

To avoid having your HttpModule called for static files, configure it in web.config to use preCondition="managedHandler".

In case it helps, event handlers in Global.asax are not called for static files.

Also, be aware that all HttpModules are called for all files when you're testing with Cassini.