C # MVC using default option

I am using MVC 4.

My default route is on my site Home/Index, so when a user enters a URL www.example.com, he goes to that route.

Could you tell me if it is also possible to get the parameter added to this URL, i.e. www.example.com/param? It works if I use www.example.com/Home/Index/param, but it is not perfect.

I guess what I need to add in Global.asax, but I can not find examples anywhere.

+4
source share
1 answer
        context.MapRoute(
            "Home_all",
            "/{*actions}",
            new { controller = "Home", action = "Index"}
        );

, URL-, :) , ... URL-,

    public ActionResult Index(string actions, string id)
    {
    }
+2

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


All Articles