简体   繁体   中英

How to access a web service using a proxy in c#

I wish to send a HTTP request to a remote web service using the specified proxy. Is this achievable? if so how?

Thank you.

var proxy = new WebProxy("proxy.example.com", 8080)
{
    Credentials = new NetworkCredential("login", "password") // optional
};

var request = new WebRequest
{
    Proxy = proxy // optional. if null - request goes without proxy, obviously
};

var response = request.GetResponse();

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