I am trying to develop a simple single sign on solution using ashx file for setting/deleting cookies. .Net 4.0, C#.
I am making a web request (from sitea.com/) to an ashx resource (on a different domain siteb.com/file.ashx) to set a cookie, then I make another request (from sitec.com/) to the same resource (at siteb.com/file.ashx) to see if the same cookie exists. Unfortunately, it comes back as null. When I fiddle it, I can see cookie being there (in request/response headers on siteb.com) on both occasions.
What I don’t understand is, how can it be not available via code. I tried using context.Request.Cookies (context comes from public void ProcessRequest(HttpContext context) method), HttpContext.Current.Request.Cookies, also on Response, but no success.
HttpCookie AuthCookie = context.Request.Cookies["SiteCookie"];
PS: I am writing code on all ends, that is making requests and checking cookie validations. Any idea what could be the problem?
Cookies have domain property, see http://msdn.microsoft.com/en-us/library/system.web.httpcookie.domain.aspx. So it seems that your cookie is set for domain siteb.com, thus unavailable for other domains.