How to prevent ASP.NET MVC from handling Static files (js and images) on Windows Azure?
Asked Answered
C

2

11

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.

Copyist answered 6/9, 2011 at 14:7 Comment(0)
N
6

When used in IIS 7 Integrated mode all requests go through the managed pipeline. It is sufficiently optimized and not something that you should worry about. On the other hand if you notice that those static files are intercepted by the ASP.NET routing engine of your application you could try adding them as IgnoreRoute definitions in your Global.asax.

Nato answered 6/9, 2011 at 14:12 Comment(1)
I see. Maybe if I could prevent the HttpModules from running on those static requests...Copyist
C
7

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.)

Copyist answered 6/9, 2011 at 14:37 Comment(1)
removed the "runAllManagedModulesForAllRequests='true'" definition in the web.config did the trick for meLias
N
6

When used in IIS 7 Integrated mode all requests go through the managed pipeline. It is sufficiently optimized and not something that you should worry about. On the other hand if you notice that those static files are intercepted by the ASP.NET routing engine of your application you could try adding them as IgnoreRoute definitions in your Global.asax.

Nato answered 6/9, 2011 at 14:12 Comment(1)
I see. Maybe if I could prevent the HttpModules from running on those static requests...Copyist

© 2022 - 2024 — McMap. All rights reserved.