Why map special routes first before common routes in asp.net mvc?

The routing engine will take the first route that matches the supplied URL and attempt to use the route values in that route. The reason why this happens is because the RouteTable is used like a switch-case statement. Picture the following: int caseSwitch = 1; switch (caseSwitch) { case 1: Console.WriteLine(“Case 1”); break; case 1: … Read more

Multiple levels in MVC custom routing

You can make CMS-style routes seamlessly with a custom RouteBase subclass. public class PageInfo { // VirtualPath should not have a leading slash // example: events/conventions/mycon public string VirtualPath { get; set; } public Guid Id { get; set; } } public class CustomPageRoute : RouteBase { private object synclock = new object(); public override … Read more