示例#1
0
        public ContextModel GetContext()
        {
            var context         = SessionService.GetSessionValue <ContextModel>("Context");
            var isWebApiRequest = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath != null && HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath.StartsWith("~/ajax");

            if (!isWebApiRequest)
            {
                return(context);
            }

            const string defaultLanguage = "en";
            var          lang            = context.ActualLanguage?.InitialsLanguage ?? defaultLanguage;

            try
            {
                Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
            }
            catch (Exception)
            {
                Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo(defaultLanguage);
            }
            return(context);
        }
示例#2
0
 public void SetContext(ContextModel context)
 {
     SessionService.SetSessionValue("Context", context);
 }