[Mono-list] Send cookies in HttpWebRequest's

Chris Howie cdhowie at gmail.com
Fri Jan 4 18:41:12 EST 2008


Can you use Wireshark or another packet sniffer to verify that the cookie is
in fact not being sent?

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

> I'm sorry i forgot that line in my the sample code in my first line, but
> in my real code I got it as it should be, something like this:
>
> using System;
> using System.Net;
> using System.IO;
>
> public class Test
> {
>     public static void Main (string[] args)
>     {
>         HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("
> http://example.com");
>         CookieContainer CookieJar = new CookieContainer();
>         CookieJar.Add(new Cookie("name", "value", "/path",
> ".example.com"));
>         webRequest.CookieContainer = CookieJar;
>         HttpWebResponse webResponse =
> (HttpWebResponse)webRequest.GetResponse();
>     }
> }
>
> 2008/1/5, Chris Howie <cdhowie at gmail.com>:
> >
> > 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
> > http://www.chrishowie.com
> > http://en.wikipedia.org/wiki/User:Crazycomputers
> > _______________________________________________
> > Mono-list maillist  -  Mono-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> >
> >
>
>
> --
> Med venlig hilsen / Kind Regards
> Søren Juul
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>


-- 
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080104/88cc3e9e/attachment.html 


More information about the Mono-list mailing list