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

Community
  • 1
  • 1
user2465083
  • 595
  • 3
  • 12

2 Answers2

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;
    }
}
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
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)

Community
  • 1
  • 1
fiinix
  • 142
  • 3