I want to include theme support for the bootswatch themes in my MVC 5 app.
I want the users theme to be saved and loaded when they log in.
I have extended my user class to include the theme and can successfully set and save a theme on the edit user page.
public class User : IdentityUser
{
public string BootstrapTheme {get;set;}
}
In the BootstrapTheme property I'll save the href attribute for the bootstrap css link. eg "~/Content/bootstrap.flatly.min.css"
The plan is to set the theme in the layout page.
<link href="~/Content/bootstrap.spacelab.min.css" rel="stylesheet" />
How can I do this without querying the database on every page load?
Being able to do something like <link href="@User.BootstrapTheme" rel="stylesheet" />
would be ideal.
Here is a link on how to save it for one page using localstorage http://wdtz.org/bootswatch-theme-selector.html