[Mono-list] Send cookies in HttpWebRequest's

Chris Howie cdhowie at gmail.com
Fri Jan 4 18:28:58 EST 2008

On Jan 4, 2008 6:19 PM, Søren Juul <zpon.dk at gmail.com> wrote:

> Shouldn't i be able to send a cookie in a HttpWebRequest by adding a
> CookieContainer to the request?
> Something like this:
> HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
> CookieContainer CookieJar = new CookieContainer();
> CookieJar.Add(new Cookie("name", "value", "/path", ".domain.com"));
> HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
> (...)

Yes you should, and in fact you can, but somewhere in there you need to do:

webRequest.CookieContainer = CookieJar;

C# may be magical but it's not *that* magical.  :)

Chris Howie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080104/ba87d8b3/attachment-0001.html 

More information about the Mono-list mailing list