How to AutoDetect/Use IE proxy settings in .net HttpWebRequest

后端 未结 4 1755
情歌与酒
情歌与酒 2020-12-16 13:20

Is it possible to detect/reuse those settings ?

How ?

The exception i\'m getting is This is the exception while connecting to http://www.google.com



        
4条回答
  •  春和景丽
    2020-12-16 13:35

    HttpWebRequest will actually use the IE proxy settings by default.

    If you don't want to use them, you have to specifically override the .Proxy proprty to either null (no proxy), or the proxy settings of you choice.

     HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://news.bbc.co.uk");
     //request.Proxy = null; // uncomment this to bypass the default (IE) proxy settings
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    
     Console.WriteLine("Done - press return");
     Console.ReadLine();
    

提交回复
热议问题