Saturday, 15 March 2014

c# - Catch all routes not working using regular expression -


I know that most of the paths in the first path will capture the path. However, also / product / editing / Bleblabla (I I'm also taking the ASP.NET routing debugger):

  Public static zero register routs {routes.IgnoreRoute ("{resource} .axd / {* pathInfo} "); ("Default", "{controller} / {action} / {id}", new {controller = "home", action = "index", id = @ "\ d {1,}"}); Routes.MapRoute ("catch all", "{* path}", new {controller = "error", action = "notepad"}); }  

But this is wrong! Why? If the minimum length of 1 is not an integer, then the first path should not be matching. I should not get any control and action ... any thoughts?

Many thanks!

You must have expression in the fourth parameter. Read this: <3 p>

<3> <3> Routes. ("Product", "Product / {Product ID}", New {Admin = "Product", Action = "Details"}, New {productId = @ "\ d +"});

Regular expression \ d + one or more integer matches This bound reason causes the product route to match the following methods:

  • / Products / 3 /
  • / Products / 8999

but not the following URL:

  • / Products / Apple
  • < Li> / product


These browser requests will be controlled by any other route or, if there is no matching route, the resource is not found. error will be returned.


No comments:

Post a Comment