【问题标题】:RouteMapping works on development server but results in 404 in productionRouteMapping 在开发服务器上工作,但在生产中导致 404
【发布时间】:2013-11-14 09:37:09
【问题描述】:

我在 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 和生产版本之间的任何更改,这可能是原因。

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

【问题讨论】:

标签: c# asp.net webforms


【解决方案1】:

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

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

StackOverflow 中有与此相关的现有查询: (1)IIS 7 ignores MapPageRoute without file extentions (2)Why is MapPageRoute / RedirectToRoute working on dev machine but not on production server?

【讨论】:

    猜你喜欢
    • 2014-05-08
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    • 1970-01-01
    • 2017-08-26
    • 2016-11-05
    • 2011-03-02
    • 1970-01-01
    相关资源
    最近更新 更多