public ActionResult LocalePicker(LocalePickerFormData localePickerFormData) { if (!String.IsNullOrEmpty(localePickerFormData.SelectedCountry)) { try { JavaScriptSerializer js = new JavaScriptSerializer(); AtomiaCookieCollection cookieCollection; if (this.Request.Cookies["AtomiaCookieCollection"] != null && !String.IsNullOrEmpty(this.Request.Cookies["AtomiaCookieCollection"].Value)) { cookieCollection = js.Deserialize<AtomiaCookieCollection>(this.Request.Cookies["AtomiaCookieCollection"].Value); } else { cookieCollection = new AtomiaCookieCollection(); } AtomiaCookie aCookie = new AtomiaCookie( this.Request.ApplicationPath, this.Request.Url.Host, localePickerFormData.SelectedCountry, "OrderLocaleCookie"); cookieCollection.AddOrUpdateAtomiaCookie(aCookie); string serializedCookieCollection = js.Serialize(cookieCollection); HttpCookie cookie = new HttpCookie("AtomiaCookieCollection") { Value = serializedCookieCollection, Expires = DateTime.Now.AddYears(1) }; if (this.Request.Cookies["AtomiaCookieCollection"] != null && !String.IsNullOrEmpty(this.Request.Cookies["AtomiaCookieCollection"].Value)) { this.Response.Cookies["AtomiaCookieCollection"].Value = cookie.Value; this.Response.Cookies["AtomiaCookieCollection"].Expires = cookie.Expires; } else { this.Response.Cookies.Add(cookie); } } catch (Exception ex) { OrderPageLogger.LogOrderPageException(ex); throw; } } this.Response.Redirect(localePickerFormData.ReturnUrl); // View does not exist, but redirect wont pass if some View is not called. :/ return this.View("Index"); }
public ActionResult LocalePicker(string returnUrl) { LocalePickerFormData localePickerFormData = new LocalePickerFormData { Countries = this.GetAvailableCountries().ToArray(), ReturnUrl = returnUrl }; return this.PartialView("LocalePicker", localePickerFormData); }