vondip
vondip

Reputation: 14039

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.

Upvotes: 1

Views: 790

Answers (1)

abatishchev
abatishchev

Reputation: 100348

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();

Upvotes: 4

Related Questions