1

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Lucas
  • 11
  • 1
  • What would you like the server to respond with? I'm not totally sure what the problem is here that you'd like help with. – Max von Hippel Jun 26 '17 at 04:08
  • it seems the application page which you are trying to access is creating JWT token which is stored in the form of cookie. This Token changes each time a user logs in. That might be the reason each time you are sending a request you are getting cookie differently – Chandan Kumar Jun 26 '17 at 04:09

0 Answers0