I am creating a model,serializing & assigning into cookie and passing it to next Page. I am able to get cookie values in next page in all browser except
- MAC -Yoshemite - Safari
IOS - IPHONE 6 Mobile- Safari
Do I need to update the below code to work in Safari.
string CookieName= "dsResponse"; string json = new JavaScriptSerializer().Serialize(model); if (HttpContext.Current.Request.Cookies[CookieName] != null) { HttpContext.Current.Response.Cookies[CookieName].Expires = DateTime.Now.AddDays(-1); } HttpContext.Current.Response.SetCookie(new HttpCookie(CookieName) { Value = json, HttpOnly = false, Expires = DateTime.Now.AddSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["cookiesecond"])) });
1 Answers
Answers 1
1st: you are overwriting the cookie - not expiring it with this code. The response object is sent once - with your "new" cookie. If the cookie exists - just change its value and/or the content. I would check your assumption on AppSettings["cookiesecond"]
Also try this:
If Request.ServerVariables("http_user_agent").IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) <> -1 Then Me.Page.ClientTarget = "uplevel"
It may be the browser caps not matching...
0 comments:
Post a Comment