开发者

How to host MVC application in IIS 7.0?

I created a MVC application which is working f开发者_如何学Goine in the local host. I published the project using visual studio to a local folder and uploaded it to the FTP location. But on server its not working.

I followed a couple of tutorials but no result http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx

Is there some good tutorials or could someone help please? Thanks


There are a couple of things that you could check:

  1. Check under which application pool the application runs, and check that the application pool uses the integrated pipeline instead of classic.
  2. Check that the web.config file contains <system.webServer> element. This is the place where the HttpModules are registered if you are using the integrated pipeline.
  3. Check that the <modules> element has the attribute runAllManagedModulesForAllRequests set to "true". This causes the HttpModules to work for all requests, allowing the UrlRouteModule to do it's work. You also have to remove and add the HttpModules.

Basically, the <system.webServer> section in web.config should contain something like this:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="ScriptModule"/>
        <remove name="UrlRoutingModule"/>
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </modules>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated"/>
        <remove name="ScriptHandlerFactory"/>
        <remove name="ScriptHandlerFactoryAppServices"/>
        <remove name="ScriptResource"/>
        <remove name="MvcHttpHandler"/>
        <remove name="UrlRoutingHandler"/>
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    </handlers>
</system.webServer>

(note that in this case version 1.0 of the MVC platform is used. you should not copy & paste this fragment. It's purely an indication of what it should look like)


We've had problems getting running. Usually (but not always), installing ASP.NET MVC on the server via the Web Platform Installer seems to fix whatever the problem is. YMMV.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜