Cookies C#.Net HTML敏捷包 [英] Cookies C# .Net Html Agility Pack

查看:81
本文介绍了Cookies C#.Net HTML敏捷包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var a ="https://www.corfo.cl"; HttpWebRequestpetición=(HttpWebRequest)WebRequest.Create(a); request.UserAgent ="Mozilla/5.0(Windows; U ; Windows NT 6.1; zh-CN; rv:1.9.1.5)Gecko/20091102 Firefox/3.5.5; request.method =" get; IWebProxy prox = request.Proxy; prox.Credentials = CredentialCache.DefaultCredentials; var getHtmlWeb =新的HtmlWeb(); getHtmlWeb.UseCookies = true; galletas CookieContainer =新的CookieContainer(); request.CookieContainer = galletas; HttpWebResponse respuesta =(HttpWebResponse)request.GetResponse(); var pagtinaInicio = Load /pre>

解决方案

请以英语发布您的问题.


Www.corfo.cl is based on the cookie to work, when it is requested www.corfo.cl, it is sent first in www.corfo.cl/sites/cpp/home, then in / sites / folder, cookie is established Jsessionid = OHS_1 ~ T8w78ZolfWgr3ZoEBBvE81nBiXbXIdjfF1In3bgpZiYvL_w8TF4p! 1081543155! -596930586 etc.

With this cookie, this page is built with all / some components related to this jsession.

If the client code does not deal with this logic, the server resets the connection as expected, because the server does not know how to build this page without jsessionid.

How can I set the cookie so I can enter the page? The code I have on the following page:

var a = "https://www.corfo.cl";HttpWebRequest petición = (HttpWebRequest) WebRequest.Create (a);request.UserAgent = "Mozilla / 5.0 (Windows; U; Windows NT 6.1; en-US; rv: 1.9.1.5) Gecko / 20091102 Firefox / 3.5.5";request.method = "get";IWebProxy prox = request.Proxy;prox.Credentials = CredentialCache.DefaultCredentials;var getHtmlWeb = new HtmlWeb ();getHtmlWeb.UseCookies = true;galletas CookieContainer = nuevo CookieContainer ();request.CookieContainer = galletas;HttpWebResponse respuesta = (HttpWebResponse) request.GetResponse ();var paginaInicio = getHtmlWeb.Load (a);


解决方案

Please post your question in English.


这篇关于Cookies C#.Net HTML敏捷包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆