. NET web service and HTTP Proxy FAQ

Source: Internet
Author: User

ExampleCodeAs follows:
WebProxy proxy = new WebProxy ("XXX. XXX", Port );
Proxy. Credentials = new networkcredential ("user", "pass", "Domain ");
// For domain user authentication, you can directly use: credentialcaches. defaultcredential;

// Prepare Web request...
Httpwebrequest myrequest = (httpwebrequest) webrequest. Create ("http://www.google.com ");
Myrequest. method = "get ";

Myrequest. Proxy = proxyie;

Description
1. Create a WebProxy, specify the proxy IP address and port, and set its credentials, that is, the user/password to log on to the proxy server;
2. Set the proxy attribute of webrequest
If it is a WebService, it also has the proxy attribute, and the settings are the same.

The above code is in a non-Asp.net WebProgramBut the web program also needs to add the following items in Web. config:
<System.net>

<Defaultproxy>
<Proxy
Usesystemdefault = "false"
Proxyaddress = "http://XXX.XXX.XXX: Port"
Bypassonlocal = "true"
/>
</Defaultproxy>
</System.net>

In. NET 2.0 has the auto proxy detection mechanism, which can automatically obtain proxy settings and try all possible proxies in a certain order. The advantage is that you do not need to set a proxy information in the code, you can obtain the latest proxy settings without restarting the application. for details, see the reference address below.

Unsolved problems:
Like QQ, proxy settings are allowed to be set to IE, that is, you do not need to enter the proxy server information again and directly use the settings in IE. no solution has been found.

Ref:
Http://msdn.microsoft.com/msdnmag/issues/05/08/AutomaticProxyDetection/default.aspx

Http://support.microsoft.com/default.aspx? SCID = KB; en-US; 330221

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.