开发者

StopRoutingHandler issue and asp.net webform routing

开发者 https://www.devze.com 2023-04-05 00:41 出处:网络
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:

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

精彩评论

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