0

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

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

If the client code does not handle 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 that cookie so that you can enter the page? The code I have is the following:

var a = "https://www.corfo.cl";
HttpWebRequest request = (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;
CookieContainer cookies = new CookieContainer();
request.CookieContainer = cookies;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
var paginaInicio = getHtmlWeb.Load(a);
Andrés
  • 31
  • 3

1 Answers1

0

If you can obtain the jsessionid from an anonymous request, you may be able to create a cookie and add it to your cookie container. I'm not sure what you have going on outside the code you posted, but it looks like you are including an empty instance of CookieContainer "cookies".

You may be able to add a cookie to the CookieContainer with the declaration below if you know the name and value

Cookie chocolateChip = new Cookie("CookieName", "CookieValue") { Domain = "DomainName" };

The Cookie instance code is from this SO question: HttpWebRequest: Add Cookie to CookieContainer -> ArgumentException (Parametername: cookie.Domain)

Ryan Boken
  • 453
  • 4
  • 11
  • The code is only the one above, there is nothing outside. When you run, an error occurs: {"Authentication failed because the remote party has closed the transport stream."} I added what you say but it still does not work. – Andrés May 25 '17 at 23:33