I'm developing a .net mvc4/5 site that presents a gui for users of third party companies. We would like to change some of the style elements on the site like the logo or some css based on what company the user belongs to.
Right now I'm saving the user belonging in a mvc Session and have created partial views for the items I like to change. In the view I'm checking the session variable and based on that I present the correct logo.
Example
@if (Session["affiliation"] != null)
{
var affiliation = Session["affiliation"].ToString();
if (affiliation == "Company1")
{
<img src="~/Content/img/logo1.png" class="navbar-logo" />
}
else if (affiliation == "Company2")
{
<img src="~/Content/img/logo2.png" class="navbar-logo" />
}
}
This will obviously not scale. Does anyone have a better solution? Ideally I would like to base the style of the page elements on the route. So that, for instance http://www.page.com/Company1 and http://www.page.com/Company2 points to the same controller but some of the information in the view changes based on the route elements. Is this possible without creating too much clutter in the view?