简体   繁体   中英

How do I call httpwebrequest c# .net

I am trying to learn how to use proxies..

My main goal is to be able to input a proxy adress in a text box and use that input as an actual proxy adress for the webBrowser in c#

But first what I need to figure out is how do I call the httpwebrequest?

I was looking at this question and the answers below and I was trying to follow along but when ever I try to use the httpwebrequest it doesnt even pop up in intellisense.

Im refering to this line right here

HttpWebRequest request = WebRequest.Create(postUrl) as HttpWebRequest;

how to use http post with proxy support in c#

Here is my code in button click calls HttpWebRequest that redirects to google home page that you can get either XML or HTML and you can also redirects to page.

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.google.co.in");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            //Get response as stream from httpwebresponse
            StreamReader resStream = new StreamReader(response.GetResponseStream());
            //Create instance for xml document
            XmlDocument doc = new XmlDocument();
            //Load response stream in to xml result
            xmlResult = resStream.ReadToEnd();
            //Load xmlResult variable value into xml documnet
            doc.LoadXml(xmlResult);

Please refer this image 1 and snapshot2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM