4

I have 2 different routes:

context.MapRoute(
    "zyzzyva_default",
    "{urlTitle}",
    new { area = "zyzzyva", action = "Index", controller = "Home", urlTitle = UrlParameter.Optional }
);

and second:

context.MapRoute(
    "Vip_default_vip_thankyou",
    "{partnername}-vip-thank-you",
    new { controller = "Vip", action = "ThankYou", partnername = "" },
    new string[] { "Web.Areas.Vip.Controllers" }
);

When I go to mydomain.com/aaaa-vip-thank-you it should use the second route, but I don't understand why it uses the first route instead.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    The first route is too general. routing works with first match found in order they were registered. – Nkosi Oct 11 '16 at 13:32

1 Answers1

2

The first route is too general.

Routing works with first match found in order they were registered.

Change order of mapping.

context.MapRoute(
    "Vip_default_vip_thankyou",
    "{partnername}-vip-thank-you",
    new { controller = "Vip", action = "ThankYou", partnername = "" },
    new string[] { "Web.Areas.Vip.Controllers" }
);

context.MapRoute(
    "zyzzyva_default",
    "{urlTitle}",
    new { area = "zyzzyva", action = "Index", controller = "Home",urlTitle = UrlParameter.Optional }
);
Nkosi
  • 235,767
  • 35
  • 427
  • 472