Is there any difference in performance when I use constraints in ASP MVC routes?

I recently asked a question about how to create a route that would direct to the same controller with two different paths. Here was the answer suggested to me:

routes.MapRoute(
   name: "Default2",
   url: "{section}/{id}",
   defaults: new { section = "home", controller = "Home", action = "Index", id = UrlParameter.Optional },
   constraints: new { section = "admin|home" });

I also did some more research and came up with this solution:

routes.MapRoute(
   "spa",
   "{section}/{id}",
   new { controller = "Home", action = "Index", id = UrlParameter.Optional },
   new { section = @"home|admin" });

Does anyone know if there is any performance difference between using one or the other?

链接地址: http://www.djcxy.com/p/46536.html

上一篇: ASP.Net MVC 4路由/路由性能问题

下一篇: 在ASP MVC路由中使用约束时,性能有任何区别吗?