views:

53

answers:

2

is there any way to find out to which route my url is getting mapped in asp.net mvc.

+2  A: 

Hi. Yes it is possible and you should test your routing configuration. You Can do it using MvcContrib. They implemented several extension methods on String class that make route testing a piece of cake. Example:

[SetUp]
        public void SetUp() {
            RouteTable.Routes.Clear();
            MyApplication.RegisterRoutes(RouteTable.Routes);
        }
        [Test]
        public void Routing() {
            "~/".ShouldMapTo<HomeController>(cont => cont.Index());
            "~/home".ShouldMapTo<HomeController>(cont => cont.Home());
            "~/solutions".ShouldMapTo<HomeController>(cont => cont.Solutions());            
            "~/licences".ShouldMapTo<HomeController>(cont => cont.Licences());
            "~/company".ShouldMapTo<HomeController>(cont => cont.Company());
            "~/support".ShouldMapTo<HelpController>(cont => cont.Support());
            "~/privacy".ShouldMapTo<HelpController>(cont => cont.Privacy());
            "~/account".ShouldMapTo<AccountController>(cont => cont.Index());
            "~/account/logon".ShouldMapTo<AccountController>(cont => cont.LogOn());            
        }
Voice
+3  A: 

You could try using Phil Haacks route tester.

Joel Cunningham