C # use the default proxy server settings of the browser (Internet Explorer) (webrequest, WebClient, httpwebrequest)

Source: Internet
Author: User

In winformProgram, If it involves access to the network, then consider the proxy situation, it is necessary;. Net program using proxy, is very simple, I have written a http://www.zu14.cn/2008/10/18/csharp_proxy/

It indicates how to specify a proxy for WebClient, httpwebrequest, webrequest, ftpwebrequest, and filewebrequest.

When using IM software such as QQ, MSN, and Baidu Hi, there is usually a proxy setting in network settings. One of the options is"Use a browser to set"

 

So in our. Net Program, how to use this function is actually very easy!

Starting from. NET Framework 2.0, Microsoft providesWebrequest. getsystemwebproxyThis static method, this methodReturns the proxy configured in Internet Explorer settings of the current simulated user., Usage:

WebClientWC =NewWebClient(); WC. Proxy =Webrequest. Getsystemwebproxy ();HttpwebrequestReq = (Httpwebrequest)Webrequest. Createdefault (NewUri("Http://zu14.cn /"); Req. Proxy =Webrequest. Getsystemwebproxy ();

Is it concise and clear?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.