Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the code below to add and update cookies

C#
public ActionResult SaveUserTypeCookies(string usertype)
{
    if (Request.Cookies["User"] != null)
    {
        HttpCookie cookie = Request.Cookies["User"];
        cookie.Values["UserType"] = usertype;
        cookie.Expires = DateTime.MaxValue;
        Response.SetCookie(cookie);
    }
    else
    {
        HttpCookie cookie = new HttpCookie("User");
        //Need to remove below comment at production deployement
        //cookie.HttpOnly = true;
        //cookie.Secure = true;
        cookie.Values["UserType"] = usertype;
        cookie.Expires = DateTime.MaxValue;
        Response.Cookies.Add(cookie);
    }
    return RedirectToAction("CreateUpsID");
}


C#
And I'm using the code below to check for the existence of cookies:

@if (!(Request.Cookies["User"] != null))
{

}

C#
This code is working fine with Chrome, but when I am using IE11, cookies don't persist.
Posted
Comments
Stephen Hewison 2-Dec-15 5:19am    
Is the page processing the cookie in an iFrame? Is the page location the same the main page?
Nitin soni 2-Dec-15 5:53am    
I am check cookies at Layout page.Its a MVC application.
And setting cookies value at default page.
[no name] 2-Dec-15 5:40am    
Did you check by clearing cache, form data and cookies in IE browser. Reopen the browser and open your page. If it doesn't work then press F12 to see developer tool. Go to network tab and see the cookie values.

1 solution

common problem with IE10+ browsers , reason for this is that asp.net can not detect features of IE, this is a problem they fixed in .net 4.5

but you can trust microsoft to create massive support issues for everyone by releasing a mainstream browser that is incompatible with earlier versions of their own IDE, cost me days worth of support calls to fix their nonsense.

anyways the solution and download for teh browser files are posted here
http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900