[Mono-list] Hi, and cookies problem.

Asier asieriko@yahoo.es
Sat, 4 Dec 2004 21:30:27 +0100

El Domingo, 28 de Noviembre de 2004 14:56, Asier escribi=F3:
> Hi,
>  I'm new in the list. I've been trying with mono for the last months, but
> i've a problem.
>  I've searched in google, c# forums webs, msdn, etc. but i'm not able to
> solve it.
>  I want to login in to a web, that usese html forms, and https. This web
> has also a web certificate.
>  When i run my program, the web returns me a cookie, but this cookie is n=
> enough for continue donwloading more page contents.
>  I've tried Firefox Live HTTP Headers extension, and using it, i can see
> that the server returns 3 diferent cookies.
>  Can you help me?
>  I attach the code and firefox headers.
>   Thanks in advance.
>    Asier
It's me again,
 The problem has solved magically, i upgraded yesterday my debian sid syste=
and mono and related packages, and when i run my code, without any change, =
works fine. What a surprise when i was going to show to my 8 years cousin h=
do we do to get programs in the computer, i compiled the code and it worked!
 I attach my working code (I have modified it a bit), maybe it can be usefu=
for somebody. I'll publish it when the full app is finish.

>My Code
HttpWebRequest solicitud =3D (HttpWebRequest) WebRequest.Create(host);=20
string DatosUsuario =3DLoginString
solicitud.CookieContainer =3D new CookieContainer ();
ServicePointManager.CertificatePolicy =3D new CertPolicy();

byte[] datos =3D Encoding.Default.GetBytes(DatosUsuario);=20
solicitud.Method =3D "POST";=20
solicitud.ContentType =3D "application/x-www-form-urlencoded";=20
solicitud.ContentLength =3D datos.Length;=20

Stream sout =3D solicitud.GetRequestStream();=20
sout.Write(datos, 0, datos.Length);=20

HttpWebResponse respuesta =3D (HttpWebResponse) solicitud.GetResponse();

CookieContainer ContenedorCookies =3D new CookieContainer ();
foreach(Cookie c in respuesta.Cookies)
ContenedorCookies.Add( new Cookie (c.Name, c.Value));

solicitud =3D (HttpWebRequest) WebRequest.Create(anotherhost);=20
string Convocatoria =3D"Convocatoria=3D" + conv +=20

solicitud.CookieContainer =3D ContenedorCookies;

datos =3D Encoding.Default.GetBytes(Convocatoria);=20
solicitud.Method =3D "POST";=20
solicitud.ContentType =3D "application/x-www-form-urlencoded";=20
solicitud.ContentLength =3D datos.Length;=20

sout =3D solicitud.GetRequestStream();=20
sout.Write(datos, 0, datos.Length);=20

respuesta =3D (HttpWebResponse) solicitud.GetResponse();
Stream stream =3D respuesta.GetResponseStream ();