19

我有一个用 Cassini 开发和测试的 mvc 应用程序。部署到我在 GoDaddy 上的站点,默认页面正常。点击登录,我得到一个 404。

我在那里运行在 IIS 7 下,所以这是出乎意料的。我的路线很简单:

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",                                              
            "{controller}/{action}/{id}",                           
            new { controller = "Public", action = "Index", id = "" } 
        );
        routes.MapRoute(
            "Report1",
            "Report/{action}/{start}/{end}",
            new { controller = "Report", action = "Index" }
        );
        routes.MapRoute(
            "Report2",
            "Report/{action}/{start}/{end}/{idList}",
            new { controller = "Report", action = "Index" }
        );

知道可能发生了什么或如何解决此问题?

4

4 回答 4

31

您是否在 IIS7集成模式下运行

IIS7 的经典模式不会自动将无扩展名 URL 映射到 ASP.NET(很像 IIS6)。

还要确保您的Web.config <system.webServer>标签配置正确。

于 2009-04-01T12:19:14.877 回答
24

不要使用 runAllManagedModulesForAllRequests。您想让 IIS 处理图像等资源。

<system.webServer> <!-- Rather do NOT use this -->
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

而是添加 MVC 路由模块

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>
于 2013-05-10T04:34:00.823 回答
14

尝试了一切,我必须像这样设置我的网络配置,以使其工作。

 <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
于 2011-02-15T00:38:04.877 回答
1

我有同样的问题,我上传了控制器、web.config 和其他类,但我忘了上传 bin 文件夹。

在我上传 bin 文件夹后,它工作了!

于 2013-12-12T11:00:01.233 回答