Asp.net mvc routing

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

+3
source share
2 answers

You can try using the Phil Haas Tester route .

+3
source

Yes, it is possible, and you should check your routing configuration. You can do this with MvcContrib. They implemented several extension methods for the String class that make route validation 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());            
        }
+2
source

Source: https://habr.com/ru/post/1748705/


All Articles