public CoreController() { _accountRepository = new AccountRepository("cmsdbConnection"); Guid userId = Guid.Empty; var domainUrl = ""; if (System.Web.HttpContext.Current != null) { var context = System.Web.HttpContext.Current; if (context.Request != null && context.Request.Url != null && !string.IsNullOrEmpty(context.Request.Url.Host)) { domainUrl = context.Request.Url.Host.ToLower().Replace("www.", ""); } if (context.User != null && context.User.Identity != null && !string.IsNullOrEmpty(context.User.Identity.Name)) { try { userId = Guid.Parse(System.Web.HttpContext.Current.User.Identity.Name); } catch (Exception ex) { throw new Exception("Не удалось определить идентификатор пользователя" + ex); } } } _cmsRepository = new cmsRepository("cmsdbConnection", userId, RequestUserInfo.IP, domainUrl); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); _accountRepository = new AccountRepository("cmsdbConnection"); //_cmsRepository = new cmsRepository("cmsdbConnection"); //SettingsModel Settings = _cmsRepository.getCmsSettings(); Guid userId = Guid.Empty; var domainUrl = ""; if (System.Web.HttpContext.Current != null) { var context = System.Web.HttpContext.Current; if (context.Request != null && context.Request.Url != null && !string.IsNullOrEmpty(context.Request.Url.Host)) { domainUrl = context.Request.Url.Host.ToLower().Replace("www.", ""); } if (context.User != null && context.User.Identity != null && !string.IsNullOrEmpty(context.User.Identity.Name)) { try { userId = Guid.Parse(System.Web.HttpContext.Current.User.Identity.Name); } catch (Exception ex) { throw new Exception("Не удалось определить идентификатор пользователя" + ex); } } } _cmsRepository = new cmsRepository("cmsdbConnection", userId, RequestUserInfo.IP, domainUrl); #region Метатеги ViewBag.Title = "Авторизация"; ViewBag.Description = ""; ViewBag.KeyWords = ""; #endregion }