3

I would like to know how to use a Proxy in a HttpWebRequest within a Portable Class Library (PCL).

I read here that the IWebProxy interface did not have any implementation within the Microsoft.Net.Http library.

I need my HttpWebRequest to use a WebProxy. Any idea on how to do this in a PCL?

Thanks for the help

2 Answers 2

1

It seems you can use your own implementation of IWebProxy (I haven't tested it on WinRT, but it works on the desktop with HttpClient)

class MyProxy : IWebProxy
{
    private readonly Uri _proxyUri;
    public MyProxy(Uri proxyUri)
    {
        _proxyUri = proxyUri;
    }

    public ICredentials Credentials { get; set; }
    public Uri GetProxy(Uri destination)
    {
        return _proxyUri;
    }
    public bool IsBypassed(Uri destination)
    {
        return false;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

HttpClient seems to exist in PCL, which can be used like this: Using a proxy with .NET 4.5 HttpClient (You may find an answer in this if i see it correctly)

1 Comment

The problem is not HttpClient, but the fact that the WebProxy class doesn't exist in WinRT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.