I have a website developed using ASP.Net MVC. Now I want to based on the request(based on the country) I want to change the web site theme.
Ex: for USA - theme 1 for Canada - theme 2
If the request is not matching to any theme I want to display default (my current theme).
How can I achieve this dynamically.
Do I need to rewrite my css again or Is there a better way to this?
Please share your ideas
Thanks in Advance :)
You should define a global css file for common styles. Assuming you have some kind of helper method for accessing the current country, you can conditionally load the country specific stylesheet, or load a stylesheet based on a rule e.g. stylesheet with the same name as the country (following code is untested):
<link rel="stylesheet" type="text/css" href="css/global.css">
// conditional
@if (SiteHelper.CurrentCountry == "USA") {
<link rel="stylesheet" type="text/css" href="css/usa.css">
}
// or assume a css file exists with the country name
<link rel="stylesheet" type="text/css" href="css/@(SiteHelper.CurrentCountry).css">
I would generally recommend using a different layout page for each country/theme as it gives you much more control. Essentially you would move the above logic into _ViewStart.cshtml and set the Layout based on the current country.