How could I route to the /Home/Index action regardless of the URL?

前端 未结 2 658
情书的邮戳
情书的邮戳 2021-01-29 03:43

I am looking for a way to route all traffic to my Home controller and to the Index action, regardless of the URL they use to arrive at my site.

As long as they are usi

相关标签:
2条回答
  • 2021-01-29 04:25

    When setting your routes, you may try defining a default route as the last route definition

        routes.MapRoute(
            "Default",
            "{*any}",
            new { controller = "Home", action = "Index" }
        );
    

    Hope this will help

    0 讨论(0)
  • 2021-01-29 04:27

    There exists a file Global.asax.cs in root of your solution where logic for routing is written, modify the logic according to your requirement.

    0 讨论(0)
提交回复
热议问题