You have to change
"UI.Controllers"
to
new[] { "UI.Controllers" }
in the second route.
If you specify only one line (and not an array), you get the MapRoute
function overloaded MapRoute
- instead of MapRoute(RouteCollection, String, String, Object, String[])
, which takes a list of namespaces as the last parameter, you get MapRoute(RouteCollection, String, String, Object, Object)
, which expects restrictions as the last parameter. The string "UI.Controllers" is not a valid specification of the constraint => you get an error.
Also, as @Pankaj suggested that your custom route follow before default, and Verify should be without "{}".
Full code:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "AccountVerify", "Account/Verify/{userName}/{authorisationToken}", new { controller = "Account", action = "Verify", userName = "", authorisationToken = "" }, new [] { "UI.Controllers" } ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } ,// Parameter defaults new[] { "UI.Controllers" } ); }
Sergey Kudriavtsev
source share