8

What is the available implementation of the System.Net.IWebProxy (from System.Net.Primitives, DNX Core)? By application requirement, the only framework can be used in dnxcore50, so what is the right NuGet package that contains proxy implementations?

What is the correct way to resolve such questions? Related functionality seems to be split among dozen of packages.

Pavel Baravik
  • 173
  • 1
  • 9

3 Answers3

10

Despite the name, IWebProxy implementation does not actually need to implement any proxying, it just provides information about the proxy. So, you can create your own implementation:

public class MyProxy : IWebProxy
{
    public Uri GetProxy(Uri destination)
    {
        return new Uri("http://localhost:8888");
    }

    public bool IsBypassed(Uri host)
    {
        return false;
    }

    public ICredentials Credentials { get; set; }
}
alex
  • 12,464
  • 3
  • 46
  • 67
3

There is a WebProxy class in the System.Net namespace (source here) that you can use.

Mark Vincze
  • 7,737
  • 8
  • 42
  • 81
0

Make sure your project.json file has these two lines under "dependencies"

"frameworks": {
    "dotnet5.4": {
      "dependencies": {
        "Microsoft.Net.Http": "2.2.29",
        "System.Net.Primitives": "4.0.11-beta-23516"
      }
    }
}
charlybones
  • 309
  • 4
  • 12
  • 1
    When I try to add there dependencies I get errors: "Package Microsoft.Net.Http 2.2.29 is not compatible with netstandard1.6", "Package Microsoft.Bcl 1.1.10 is not compatible with netstandard1.6" – Konstantin Vdovkin Mar 27 '17 at 11:05