Reputation: 7113
I want every link like:
mysite.com/England/English
mysite.com/France/French
mysite.com/Canada/French
To open in this action:
public ActionResult Country(string country, string language)
but if it's the About:
mysite.com/About
should go to:
public ActionResult About()
everything else should go to homepage
public ActionResult Index()
I've tried doing like this:
routes.MapRoute(
"NewRoute",
"{id}",
new {controller = "Home", action = "Country", id = UrlParameter.Optional}
);
routes.MapRoute(
"AboutRoute",
"About",
New {controller = "Home", action = "About", id = UrlParameter.Optional}
);
Upvotes: 0
Views: 148
Reputation: 822
You should put more specific routes at the top. Add catch all route at the end. Try
routes.MapRoute(
"AboutRoute",
"About",
New {controller = "Home", action = "About"}
);
routes.MapRoute(
"NewRoute",
"{country}/{language}",
new { controller = "Home", action = "Country" }
);
routes.MapRoute(
"CatchAll",
"{*path}",
new { controller = "Home", action = "Index" }
);
Upvotes: 1