Вы можете использовать OnActionExecuted
метод в вашем контроллере в сочетании с Dynami c ViewBag
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (Request.IsAjaxRequest() || filterContext.IsChildAction) return; // you don't need styling for ajax requests which return json
base.OnActionExecuted(filterContext);
YourUser user = ... // get user from db/claims or get theme from cookies etc.;
ViewBag.DarkTheme = user.DarkTheme;
}
, и в связи с этим он будет вызываться просто @ViewBag.DarkTheme
, пространство имен не требуется