开发者

Difference in URL Routing?

开发者 https://www.devze.com 2023-03-19 01:17 出处:网络
Is there a difference between the url rewriting in the web config and using the url routing within the global.asax?

Is there a difference between the url rewriting in the web config and using the url routing within the global.asax?

<rewrite>
  <rules>
    <rule name="Rewrite to article.aspx">
      <match url="^article/([0-9]+)/([_0-9a-z-]+)" />
      <action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}" />
    </rule>
  </rules>
</rewrite>

Global.asax

void Application_Start(object sender, EventArgs e) 
{
    RouteTable.Routes.MapPageRoute("Category", "categories/{name}", "~/ShowPostsByCategory.aspx");
   开发者_如何学C RouteTable.Routes.MapPageRoute("BlogPost", "posts/{year}/{month}/{day}/{id}", "~/ShowPost.aspx");
}


URL Rewriting is handled at the IIS level and directs the request at the web server level. ASP.NET Routing handles directing a request to the appropriate handler at the Application level. Look at the link below for more details.

IIS URL Rewriting verses ASP.NET Routing

0

精彩评论

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