0

我在我的asp.net网站中使用url路由。我把colde放在glocal.asax Application_Start事件中,无效

Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        RouteTable.Routes.MapPageRoute("routedetail",
      "alllist/special/{Name}",
      "~/sub/mydetail.aspx");

        RouteTable.Routes.MapPageRoute("routelist",
            "alllist/special",
            "~/sub/mylist.aspx");


        RouteTable.Routes.MapPageRoute("routehtml", "alllist/myhtml.html", "~/sub/to.aspx");
    }

在我的本地开发和 iis7 中一切都很好。错误是在线托管
“routehtml”不起作用。访问被拒绝。是 .html 扩展名吗?我该如何解决这个问题。任何建议..

4

2 回答 2

0

You may want to check that your IIS 7 Application Pool is in Integrated mode on your host server. It will not work if it isn't. Although you wouldn't need it, but you could also set RouteExistingFiles property to false at the top of your Application_Start event.

于 2012-09-23T12:31:29.513 回答
0

尝试将其放入 global.asax

void Application_BeginRequest(object sender, EventArgs e)
{
   HttpApplication app = sender as HttpApplication;
   if(app.Request.Path.IndexOf("FriendlyPage.html") > 0)
   {
       app.Context.RewritePath("/UnfriendlyPage.aspx?SomeQuery=12345");
   }
}
于 2012-09-23T11:38:03.407 回答