【问题标题】:MVC.NET Routing works in development server but not on IIS 7.0MVC.NET Routing 在开发服务器上工作,但在 IIS 7.0 上不工作
【发布时间】:2010-09-15 15:42:27
【问题描述】:

我已将我们的项目从网站升级为网络应用程序并导入到 VS2k10。

我添加了以下参考:

System.Web.Abstractions

System.Web.MVC

System.Web.Routing ...

将目标框架更改为 4.0...

添加了一个控制器“HomeController.cs”...现在可以在开发服务器中使用,但不能在 IIS 7.0 中使用

Windows 服务器 2k8 r2 VS2010 .net 框架 4.0

应用程序池在集成管道模式下运行...我有点困惑为什么它可以在开发服务器上运行但不能在 IIS 上运行...

<system.webServer>
    <modules>
        <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" preCondition="managedHandler" />
        <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
        <add name="Page" type="Impark.MPS.SelfServe.UIL.GlobalPageEvents, PageEventsModule" preCondition="managedHandler" />

    </modules>
    <handlers>
        <add name="*.vbhtml_*" path="*.vbhtml" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.vbhtm_*" path="*.vbhtm" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.cshtml_*" path="*.cshtml" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.cshtm_*" path="*.cshtm" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.aspq_*" path="*.aspq" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.xamlx_*" path="*.xamlx" verb="*" type="System.Xaml.Hosting.XamlHttpHandlerFactory, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.xoml_*" path="*.xoml" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.rules_*" path="*.rules" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.svc_*" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.soap_*" path="*.soap" verb="*" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.rem_*" path="*.rem" verb="*" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*.asmx_*" path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="ScriptResource.axd_GET,HEAD" path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="*_AppService.axd_*" path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" />
        <add name="eurl.axd_*" path="eurl.axd" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode,runtimeVersionv2.0" />
    </handlers>
    <validation validateIntegratedModeConfiguration="false" />
</system.webServer>

对不起,忘了说。在开发服务器上,我得到了预期的响应。我在 IIS 中得到相同的 URL: 错误摘要 HTTP 错误 404.0 - 未找到 您要查找的资源已被删除、名称已更改或暂时不可用。

【问题讨论】:

  • 您是否确定已将所有必要的文件移至故障机器。错误是说找不到文件?
  • 相同的物理机和相同的路径... IE 没有文件移动... 但我只是找到了一个线索... 当我在开发服务器中添加虚拟服务器路径时,它现在也失败了。 .. IE localhost:9999/Home 有效...但localhost:9999/Company.project.SubProject.Target/Home 无效

标签: asp.net-mvc iis-7.5 windows-server-2008-r2


【解决方案1】:

如果您使用的是 .Net 4.0,则应从 preCondition 中删除 runtimeVersionv2.0

【讨论】:

    猜你喜欢
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    • 2017-06-05
    • 2011-05-30
    • 1970-01-01
    • 2010-10-18
    • 1970-01-01
    相关资源
    最近更新 更多