Cats.Web.Hub.BaseController.ExecuteCore C# (CSharp) Method

ExecuteCore() protected method

Invokes the action in the current controller context.
protected ExecuteCore ( ) : void
return void
        protected override void ExecuteCore()
        {
            string cultureName = null;

            //get the current user and chek if she/he set the LanguageCode
            if (User.Identity.IsAuthenticated)
            {
                try
                {

                    cultureName = this.GetCurrentUserProfile().LanguageCode;
                }
                catch (Exception e)
                {
                    cultureName = "en";
                }
            }
            else
            {
                // Attempt to read the culture cookie from Request
                HttpCookie cultureCookie = Request.Cookies["_culture"];
                if (cultureCookie != null)
                    cultureName = cultureCookie.Value;
                else
                    cultureName = "en";//Request.UserLanguages[0];  obtain it from HTTP header AcceptLanguages
            }
            // Validate culture name
            cultureName = CultureHelper.GetImplementedCulture(cultureName); // This is safe

            // Modify current thread's cultures
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "dd-MMM-yyyy";

               base.ExecuteCore();
        }