0

Hello i making a simple httpwebrequest and then i read (StreamReader) the response and just want to get the html page of website,but i get only one laber(only one element of the page) in the browser all fine(i see all page) but when i try to set cookies to Deny\disable i also in the browser get this label(only one element of the page) and all is disappear.Sow i getting opinion if after i disabled cookies in browser i get the same page(like in code) that mean my HttpWebRequest is have settings cookies=deny/disable.

You can go to https://www.bbvanetcash.com/local_kyop/KYOPSolicitarCredenciales.html and disable cookies with F12 and you will see the difrance and also this page with one label.

Sow this my code any ideas what i need to change here?

HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("https://www.bbvanetcash.com/local_kyop/KYOPSolicitarCredenciales.html");

HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream streamResponseLogin = myHttpWebResponse.GetResponseStream();
StreamReader streamReadLogin = new StreamReader(streamResponseLogin);
LoginInfo = streamReadLogin.ReadToEnd();
Vladimir Potapov
  • 2,347
  • 7
  • 44
  • 71

1 Answers1

1

Your code is receiving complete page content, but it cannot receive the dynamic contents. This is happening because the page you are trying to access relies on Cookies for maintaining session as well as JavaScript (it is using jQuery) for loading dynamic contents and providing rich user experience.

To successfully receive the whole page, your code must

  • support retrieving, storing and sending cookie objects across various HttpRequest and HttpResponse.
  • be able to execute JavaScript code to load the dynamic contents/markup of the page

To test 'if your code is receiving proper values or not' visit the site Web Sniffer and put your URL there.

As you can try on web-sniffer site, for www.google.com, the response you are getting is a redirect instruction.... that means, even to access the Google's home page, your code must understand HTTP status messages (302 there).

Manish Dalal
  • 1,768
  • 1
  • 10
  • 14
  • @VovaPotapov: Writing these functionality will make a basic browser. I don't have any such code with me. Each functionality is very vast, like handling all HTTP status messages, each one having various attributes. interpreting and executing JavaScript codes; maintaining & storing cookies, GET and POST handling, rendering the content on the UI, CSS handling, etc, etc, etc...... – Manish Dalal Apr 28 '14 at 09:58
  • 1
    Some open source browsers are listed here http://stackoverflow.com/questions/814757/headless-internet-browser – Manish Dalal Apr 28 '14 at 10:01