El Domingo, 28 de Noviembre de 2004 14:56, Asier escribió:
> 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 not
> 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 system, 
and mono and related packages, and when i run my code, without any change, it 
works fine. What a surprise when i was going to show to my 8 years cousin how 
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 useful 
for somebody. I'll publish it when the full app is finish.

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

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

Stream sout = solicitud.GetRequestStream(); 
sout.Write(datos, 0, datos.Length); 
sout.Flush(); 
sout.Close(); 

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

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

solicitud = (HttpWebRequest) WebRequest.Create(anotherhost); 
string Convocatoria ="Convocatoria=" + conv + 
"&Enviar=Consultar+Calificaciones"; 

solicitud.CookieContainer = ContenedorCookies;

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


sout = solicitud.GetRequestStream(); 
sout.Write(datos, 0, datos.Length); 
sout.Flush(); 
sout.Close(); 

respuesta = (HttpWebResponse) solicitud.GetResponse();
Stream stream = respuesta.GetResponseStream ();
_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to