MVC routing is not working sometimes

时间:2016-07-11 22:06:30

标签: asp.net-mvc-routing

I have routing in MVC 5 as:

context.MapRoute(
           "cart_contact",
           "Cart/MyContact",
           new { controller = "Shopping", action = "MyContact" }
       );
        context.MapRoute(
             "cart_shipping",
             "Cart/MyShipping",
             new { controller = "Shopping", action = "MyShipping" }
         );
        context.MapRoute(
             "cart_payment",
             "Cart/MyPayment",
             new { controller = "Shopping", action = "MyPayment" }
         );
        context.MapRoute(
            "cart_default",
            "Cart",
            new { controller = "Shopping", action = "Index" }
        );

when I have Url as: /Cart/MyContact, sometimes I'm hitting "MyContact" action, sometimes I'm hitting "Index" action, "MyShipping" and "MyPayment" has same problem too, sometimes hitting the "MyShipping" or"MyPayment" action, but sometimes hitting "Index" action, could anybody help me check what's wrong with my routing? what I want is those different endpoint should always hit different action.

Your help is great appreciated.

Thanks

Oreo

0 个答案:

没有答案