0

我在 Global.asax 中有以下代码,在带有 webforms 的网站项目中,而不是 MVC 应用程序:

void Application_Start(object sender, EventArgs e) 
{
    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapPageRoute("Documents", "documents/{document-id}/", "~/GetDocument.aspx");
}

路由映射在我运行 IIS Express 的开发环境中正常工作,但在生产中它返回 404 错误。

服务器运行 IIS 7 并具有几乎相同的 web.config 文件。我无法确定可能是原因的 dev web.config 和生产版本之间的任何更改。

为什么我的路由映射在我的开发环境中有效,但在我的生产环境中无效?

4

1 回答 1

1

您是否尝试在 web.config 中指定 runAllManagedModulesForAllRequests="true ?

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>

StackOverflow 中有与此相关的现有查询:(1) IIS 7 忽略没有文件扩展名的 MapPageRoute (2)为什么 MapPageRoute / RedirectToRoute 在开发机器上工作而不在生产服务器上工作?

于 2014-11-13T04:22:25.867 回答