问题
So far, the only successful strategy I've been able to get by with is the following:
- Configure YOURAPP.Web to "Use Local IIS Web Server" and set "Project Url" = http://localhost/yourapp.web
- Click "Create Virtual Directory"
- In IIS Manager ensure that "Classic .NET App Pool" is selected
- 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
回答1:
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.
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/1157988/best-way-to-deploy-an-asp-net-mvc-app-on-iis-7-server-2008