开发者

StopRoutingHandler issue and asp.net webform routing

I came to know that StopRoutingHandler route. For example, this would stop routing on all js files. We could also set it up to ignore the entire script directory also, like below:

routes.Add(new Route("*\.jpg", new StopRoutingHandler()));

I need to know where to put the line. Do I need to put the line in Application_Start?

void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.Add(new Route("*\.jpg", new StopRoutingHandler()));
    RouteTable.Routes.MapPageRoute("Source", "UrlRewrite/Approach1/Source/{ID}/{Title}", "~/UrlRewrite/Approach1/Source.aspx");
}
开发者_StackOverflow中文版

but before MapPageRoute or after MapPageRoute? Please explain.


You'd better get a lock before writing on the route table.

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

public static void RegisterRoutes(RouteCollection routes)
{
      using (RouteTable.Routes.GetWriteLock())
      {
        routes.MapPageRoute("",
        "Category/{action}/{categoryName}",
        "~/categoriespage.aspx");
      }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜