Redirect my site to the default controller in mvc

I have an area in my project with a name Fain my area Fa, I have a controller with a name home, and inside my controller I have an action with a name index.

I published my website, but when I type in my url, I could not see my website because it should be redirected to mywebsite.com/en/home/index. How can I set this url in myMVC Project

I tried this one but it does not work.

var route = routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    ).DataTokens = new RouteValueDictionary(new { area = "fa" });
+4
source share
2 answers

you should use this code:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
                routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new {area="fa", controller = "Home", action = "Index", id = UrlParameter.Optional },namespaces: new string[] { "UI.Areas.fa.Controllers"}
            ).DataTokens.Add("area", "fa");
+2
source

. HomeControllers, , .

, .

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { area = "en", controller = "Home", action = "Index", id = UrlParameter.Optional },
    namespaces: new string[] { "UI.Areas.en.Controllers" }
);
+1

All Articles