Use proxy in C # Portable Class Library (Microsoft.Net.Http)

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

I read here that the IWebProxy interface is not implemented in the Microsoft.Net.Http library.

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

thanks for the help

+3


source to share


2 answers


It seems you can use your own implementation IWebProxy

(I haven't tested it on WinRT, but it works on desktop since 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;
    }
}

      

+1


source


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



0


source







All Articles