Cookies are not retaining any data while sent as part of a WebRequest

brewercattle

New Member
This is how I am setting up the cookies data and passing along web request. When I check the response from the website using fiddler I see cookies have no data and expiry data is set to Jan 1, 1900. Any help would be much appreciated. Please let me know if something is not clear from following code or you need more info to answer my question. Thanks.\[code\]System.Net.Cookie userType = new System.Net.Cookie("CUserType","subscriber", "/", "www.DOMAIN_NAME.com");userType.Expires = DateTime.Now.AddYears(1);System.Net.Cookie dUserType = new System.Net.Cookie("dCUserType", "subscriber", "/", "www.DOMAIN_NAME.com");dUserType.Expires = DateTime.Now.AddYears(1);System.Net.CookieContainer cookieContainer = new System.Net.CookieContainer();cookieContainer.Add(userType); cookieContainer.Add(dUserType);HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(URL);webRequest.Proxy = new WebProxy("127.0.0.1", 8888); webRequest.Referer = "http://DOMAIN_NAME/search/index.aspx?lid=3"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Date = DateTime.Now; webRequest.CookieContainer = cookieContainer;string result;using (var stream = webRequest.GetResponse().GetResponseStream())using (var reader = new StreamReader(stream, Encoding.UTF8)) { result = reader.ReadToEnd(); }\[/code\]
 
Back
Top