I have a web app that up until now has been skinned (just basic colours and logos, nothing complicated) to a single company , however now since the merging with another company the site needs to be branded as two seperate companies (operation is exactly the same for both, and they share the same data). The simplest way would be to just copy the web app and host two instances of it, but that will be a maintenance hassle, I really just want to setup a DNS alias to the same site.
Basically I want to change the theme based on the URL of the site. e.g. alpha.company.com -> Theme A beta.comany.com -> Theme B.
How would you recommend to solve this?
In your page (or base page), get on the PreInit handler (only Page has this event, not MasterPage) and do something like the following:
protected void Page_PreInit(..)
{
this.Theme = GetThemeByUrl(Request.Url);
}
private string GetThemeByUrl(Uri url)
{
string host = url.Host; //gets 'subdomain.company.com'
//determine & return theme name from host
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With