ASP.NET MVC使用URL进行驱动。

• System.Web.Routing.dll
• 独立于ASP.NET MVC框架的组件,可用于任意ASP.NET应用程序
• ASP.NET MVC框架开放源代码
• URL Routing组件目前并不开放
• 将URL转换为RouteData等数据

UrlRouting是为了让Url更简短更有意义才出现的,例如:default.aspx?year=1999&month=3&day=8 的参数URL变为 /default/1999/3/8/ 这样的简短漂亮且有意义的URL

而类似home/about.aspx?id=1,以示例中的Global.asax.cs中定义的{controller}/{action}/{id}规则为列
/Home/About/1其实就是访问 Controller="Home" Action="About" 它的一个QueryString参数为 >void RegisterRoutes(RouteCollection routes) { //不受后面规则控制,Ignore即忽略 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); //重写规则 routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); } protected void Application_Start() { RegisterRoutes(RouteTable.Routes); }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-11-23
  • 2022-12-23
  • 2021-08-22
  • 2021-05-24
  • 2021-12-14
猜你喜欢
  • 2021-09-28
  • 2021-06-27
  • 2021-10-17
  • 2021-06-29
  • 2022-12-23
  • 2021-12-07
  • 2021-11-30
相关资源
相似解决方案