I have a website that will service a few different countries. When a user hits the site, I’ll use an IP locator tool to determine which country they are from. All of the countries will speak English so the views rendered will be the same, however pricing will be different as well as a few other things.
The routing I would want is something like:
- mydomain.com/UK/Pricing
- mydomain.com/Australia/Pricing
- mydomain.com/UK/Features/SomeFeature
- mydomain.com/Australia/Features/SomeFeature
You get the idea…
Can anyone provide me with the routing I’ll need in the global.asax?
I’ve tried the following, but I don’t want to have to create views for every country:
routes.MapRoute(
"Default",
"{country}/{controller}/{action}/{id}",
new { country = "UK", controller = "Home", action = "Index", id = "" }
);
Your route should be good enough, you simply need to add an argument to your Action methods to retrieve the country value: