使用webclient发送带子密钥的cookie

时间:2017-06-26 00:27:47

标签: c# cookies webclient

我正在尝试访问WebClient课程的网页。页面login包含cookies,因此为了使用WebClient登录和管理Cookie,我使用了此代码(从网上下载)

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;
     }        
}

当我使用浏览器访问该页面时,当它发布登录数据时,服务器会返回这样的cookie

  

cookieMemo = UserCotizacion =假&安培;用户ID = 7128&安培; UsuarioLogeado = DOMIZI2282&安培; IdUsuarioLogueado = 7128&安培; PERSONIF = N&安培; FechaUltLoginAdministrativo = 00:00:00   上午&安培;农布雷= DOMIZI,JOSEFERNANDO&安培; EmailPersona=fedomizi@hotmail.com& userPersonif = DOMIZI,JOSEFERNANDO-2316992251&安培; CUIT = 2316992251;   路径= /

并在下一个请求中发送这样的cookie cookie send by browser in next request

当我尝试使用WebClient登录时,我得到相同的cookie但是当我执行下一个请求时,cookie发送错误..(至少不是浏览器) how webclient sends the cookie

0 个答案:

没有答案