我想在我的MVC 5应用程序中包含对bootswatch主题的主题支持.
我希望用户主题在登录时保存并加载.
我扩展了我的用户类以包含主题,并且可以在编辑用户页面上成功设置和保存主题.
public class User : IdentityUser
{
public string BootstrapTheme {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
在BootstrapTheme属性中,我将保存bootstrap css链接的href属性.例如 "~/Content/bootstrap.flatly.min.css"
计划是在布局页面中设置主题.
<link href="~/Content/bootstrap.spacelab.min.css" rel="stylesheet" />
如何在不加载每个页面的情况下查询数据库的情况下如何执行此操作?
能够做一些像<link href="@User.BootstrapTheme" rel="stylesheet" />
理想的事情.
以下是使用localstorage http://wdtz.org/bootswatch-theme-selector.html保存一页的链接