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