.NET Core 的 IWebProxy 实现位置 [英] Location of IWebProxy implementation for .NET Core

查看:35
本文介绍了.NET Core 的 IWebProxy 实现位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Net.IWebProxy 的可用实现是什么(来自 System.Net.Primitives、DNX Core)?根据应用需求,dnxcore50 中唯一可以使用的框架,那么包含代理实现的正确 NuGet 包是什么?

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.

推荐答案

尽管名称如此,但 IWebProxy 实现实际上并不需要实现任何代理,它只提供有关代理的信息.因此,您可以创建自己的实现:

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; }
}

这篇关于.NET Core 的 IWebProxy 实现位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆