Location of IWebProxy implementation for .NET Core
Asked Answered
S

3

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.

Separator answered 12/2, 2016 at 22:30 Comment(0)
F
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; }
}
Finagle answered 22/4, 2016 at 20:48 Comment(1)
Not having a default implementation just as you have here seems like an oversight.Tortile
R
3

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

Rost answered 8/2, 2018 at 8:18 Comment(0)
A
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"
      }
    }
}
Amperage answered 11/3, 2016 at 11:1 Comment(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"Teddytedeschi

© 2022 - 2024 — McMap. All rights reserved.