开发者

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

开发者 https://www.devze.com 2023-01-31 22:05 出处:网络
I wish to send a HTTP request to a remote 开发者_如何学Goweb service using the specified proxy. Is this achievable? if so how?

I wish to send a HTTP request to a remote 开发者_如何学Goweb 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();
0

精彩评论

暂无评论...
验证码 换一张
取 消