I am trying to access a web page with WebClient
class. The page login
with cookies
, so in order to login and managed cookies with WebClient
I used this code (downloaded from web)
public class WebClientCookie : WebClient
{
private CookieContainer _cookies;
public WebClientCookie(CookieContainer cookies)
{
_cookies = cookies;
}
protected override WebRequest GetWebRequest(Uri address)
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
request.CookieContainer = _cookies;
return request;
}
}
When I access the page with a browser, when it post login data the server return cookies like this
cookieMemo=UserCotizacion=False&UserID=7128&UsuarioLogeado=DOMIZI2282&IdUsuarioLogueado=7128&PERSONIF=N&FechaUltLoginAdministrativo=00:00:00 a.m.&Nombre=DOMIZI,JOSEFERNANDO&EmailPersona=fedomizi@hotmail.com&userPersonif=DOMIZI,JOSEFERNANDO-2316992251&cuit=2316992251; path=/
and in the next request it sends cookie like this cookie send by browser in next request
When I try to login with the WebClient
I get the same cookie
but when I do the next request the cookie
is sent wrong.. (at least not as the browser)
how webclient sends the cookie