How to host MVC application in IIS 7.0?

微笑、不失礼 提交于 2019-12-02 17:52:29

问题


I created a MVC application which is working fine 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


回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/6064868/how-to-host-mvc-application-in-iis-7-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!