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

问题描述

Www.corfo.cl基于可工作的cookie,当被请求www.corfo.cl时,首先将其发送到www.corfo.cl/sites/cpp/home,然后在/sites/文件夹中建立cookie Jsessionid = OHS_1〜T8w78ZolfWgr3ZoEBBvE81nBiXbXIdjfF1In3bgpZiYvL_w8TF4p! 1081543155! -596930586等

使用此cookie,此页面将包含与此jsession相关的所有/一些组件.

如果客户端代码未处理此逻辑,则服务器将按预期方式重置连接,因为服务器不知道如何在没有jsessionid的情况下构建此页面.

如何设置cookie以便进入页面?我在下一页上的代码:

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


解决方案


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

08-19 08:40