views:

401

answers:

3

So far, the only successful strategy I've been able to get by with is the following:

  1. Configure YOURAPP.Web to "Use Local IIS Web Server" and set "Project Url" = http://localhost/yourapp.web
  2. Click "Create Virtual Directory"
  3. In IIS Manager ensure that "Classic .NET App Pool" is selected
  4. Add wildcard mapping * named "ASP.NET-MVC" that points to IsapiModule

BUT I don't really like the idea of having the full ASP.NET pipeline invoked when requesting any resource (javascript file, stylesheet, image, etc...) which is exactly what happens with the wildcard mapping.

So is there a way around this?

Is there a better method to running mvc apps on IIS 7?

I'm definitely open to suggestions as I'm not all that satisfied with what I got so far.

Thanks - wg

A: 

Assuming that all of your CSS/JS/image files reside in the Content directory, you could add an ignore route.

routes.IgnoreRoute("Content/{*wildcard}");

This will prevent any requests to the content directory being handled by MVC.

Dan Atkinson
+1  A: 

Make sure IIS7's "Managed pipeline mode" is set to "Integrated". That has been the single most important thing to do (for me) to get my MVC app running smoothly on IIS7. Here's a good blog post too. When developing the app, I have had no issues using the "Visual Studio Development Server" for running the app.

LordHits
I tried this but I have a need to fetch "this.User.Identity" in the Application_AuthenticateRequest() method which is returning null for "this.User"When I run in classic mode, it isn't null.
wgpubs
see my comment below. but i agree, Integrated seems to be the most efficient.
wgpubs
A: 

IIS7 is designed to take all requests and push off the static file stuff efficently. I wouldn't worry about it in the same way one worries about wildcard mappings on IIS6. There is no "load ASP.NET pipeline" penalty because IIS7 is a mean honking ASP.NET pipeline all the time.

Wyatt Barnett
I have code in my Application_AuthenticateRequest() method that is being executed for everything ... every javascript, stylesheet and image on the page. And it is slowing things waaaay down.So my impression is that the ASP.NET pipeline is being invoked for these static files as well. No?
wgpubs
SOLVED. Moved this code to AuthorizeRequest() and all worked and only called ONCE vs. for each file.So I think the best practice is use Integrated and look here (http://msdn.microsoft.com/en-us/library/bb470252.aspx) for understanding when what fires and when what is available in ASP.NET when running under IIS 7 (because it is different).
wgpubs