asp.net core defaultProxy(asp.net core defaultProxy)
问题描述
在 net 4.5 中,我们正在使用这样的代理:
In net 4.5 we are working with proxy like this:
<system.net>
<!-- -->
<defaultProxy enabled="true" useDefaultCredentials="false">
<proxy usesystemdefault="True" proxyaddress="http://192.168.1.1:8888" bypassonlocal="True" autoDetect="False" />
<module type="CommonLibrary.Proxy.MyProxy, CommonLibrary, Version=1.0.0.0, Culture=neutral" />
</defaultProxy>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
<servicePointManager expect100Continue="false" />
</settings>
</system.net>
但是在 asp.net core 或 test 中我们找不到像上面这样的解决方案有人可以帮我吗?
but in asp.net core or test we can't found a solution like the above Could someone please help me?
非常感谢您的帮助
谢谢,问候
推荐答案
虽然在可以使用 HttpClientHander 时手动设置代理工作,但默认所有请求都不需要代码,就像你可以在 .NET Framework 中做目前是不可能的.如果您使用的是不公开此功能的库,那就太可惜了.
Whilst manually setting the proxy works when it's possible to use a HttpClientHander, defaulting all requests to do so without code, like you could do in the .NET Framework is currently not possible. Which is bummer if you're using a library that doesn't expose this functionality.
谢天谢地,从 .NET Core 3.0 开始,只需设置环境变量就可以实现这一点(即,其行为与 Linux 一直有效):https://github.com/dotnet/corefx/issues/37187
Thankfully, from .NET Core 3.0, this will be possible simply by setting environment variables (i.e. behaves exactly as Linux has worked forever): https://github.com/dotnet/corefx/issues/37187
或者,https://github.com/dotnet/corefx/issues/36553 在 HttpClient 上添加了一个新的静态 DefaultWebProxy 属性,这将允许您通过代码完成相同的事情.这也将在 Core 3.0 中提供.
Alternatively, https://github.com/dotnet/corefx/issues/36553 added a new static DefaultWebProxy property on HttpClient that will allow you to accomplish the same thing via code. This will also be available in Core 3.0.
这篇关于asp.net core defaultProxy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:asp.net core defaultProxy
基础教程推荐
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
