如何在 IIS 7.0 中托管 MVC 应用程序?

发布于 2024-11-08 12:44:59 字数 403 浏览 4 评论 0原文

我创建了一个 MVC 应用程序,它在本地主机上运行良好。我使用 Visual Studio 将项目发布到本地文件夹并将其上传到 FTP 位置。但在服务器上它不起作用。

我遵循了几个教程但没有结果 http://haacked.com/archive/2008/11/03 /bin-deploy-aspnetmvc.aspx http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx

有一些好的教程或者有人可以帮忙吗? 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青衫儰鉨ミ守葔 2024-11-15 12:44:59

您可以检查以下几项内容:

  1. 检查应用程序在哪个应用程序池下运行,并检查应用程序池是否使用集成管道而不是经典
  2. 检查 web.config 文件是否包含 元素。如果您使用集成管道,这是注册 HttpModules 的地方。
  3. 检查 元素的属性 runAllManagedModulesForAllRequests 设置为 “true”。这会导致 HttpModules 为所有请求工作,从而允许 UrlRouteModule 完成它的工作。您还必须删除并添加 HttpModule。

基本上,web.config 中的 部分应包含如下内容:

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

(请注意,在本例中,MVC 平台的版本 1.0 是您不应该复制并粘贴此片段,这纯粹是为了表明它应该是什么样子)

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)

鸠书 2024-11-15 12:44:59

我们在运行时遇到了问题。通常(但并非总是),通过 Web 平台安装程序在服务器上安装 ASP.NET MVC 似乎可以解决任何问题。 YMMV。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文