Get web page response by HttpWebRequest

Get web page response by HttpWebRequest in ASP.net

How to get the Web page Source to a string which is hosted outside the application. If it is available inside the application then we can use server.execute to get it with current session. But if it is not then we can use the Http Web Request using HttpWebRequest.TimeOut can to be used when the target is a heavy page.

Configure the HttpWebRequest

To read the response of the web page we have to specify the ContentType ,Method. Method can be either Post or Get depends on the requirement. If the Post is selected then forms can be filled upa and submitted. As this article’s main focus is on get posting data related information is not presented here.

StreamReader To get the response as Stream

Requester.GetResponse() can be read using  a stream reader so we can make use of the StreamReader and its ReadToEnd() method to read entire response into a string.

Leave a Reply