So I'm confused as msdn and other tutorials tell me to use HttpCookies to add cookies via Response.Cookies.Add(cookie). But that's the problem. Response.Cookies.Add only accepts Cookies and not HttpCookies and I get this error:
cannot convert from 'System.Net.CookieContainer' to 'System.Net.Cookie'
Additionally, what's the difference between Response.Cookies.Add(cookie) and Request.CookieContainer.Add(cookie)?
Thanks for the help in advance, I'm trying to teach myself using C#.
// Cookie
Cookie MyCookie = new Cookie();
MyCookie.Name = "sid";
MyCookie.Value = SID;
MyCookie.HttpOnly = true;
MyCookie.Domain = ".domain.com";
// HttpCookie
HttpCookie MyCookie = new HttpCookie("sid");
MyCookie.Value = SID;
MyCookie.HttpOnly = true;
MyCookie.Domain = ".domain.com";
Response.Cookies.Add(MyCookie);
You are using
System.Net.HttpWebResponse
. But the above example usesSystem.Web.HttpResponse
which takesSystem.Web.HttpCookie
as a parameter.Scott Allen