这是一个使用VS2015的WebApi项目.
重现步骤:
一切都工作正常,直到我将构建输出路径从"bin \"更改为"bin\Debug \"实际上,除"bin"之外的任何输出路径都不起作用.
还有一点是,只要我在"bin"中留下构建版本,就可以使用另一个输出路径到任何地方.
请帮助提供解决方案.我想这会在实际部署上造成成本问题.
我对记忆问题很新.希望你不要认为这是一个愚蠢的问题.
我知道大于85,000字节的内存将被放入C#中的LOH中
Byte[] hugeByteCollection = new Byte[85000];
Run Code Online (Sandbox Code Playgroud)
我想知道一个大小为10000 - 20000且包含10个成员变量(字节类型)的对象是否会被放入LOH或SOH?
有人知道为什么下面的策略在 3 次而不是 10 次后停止重试吗?
IAsyncPolicy<HttpResponseMessage> httpWaitAndRetryPolicy =
Policy.HandleResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode)
.OrHandle<Exception>(r => true)
.WaitAndRetryAsync(10, retryAttempt => TimeSpan.FromSeconds(2));
Run Code Online (Sandbox Code Playgroud)
我将重试尝试设置为 10 并测试 http post 调用,但 BadRequest 失败。但只重试了3次就停止了,直到超时并抛出异常
IAsyncPolicy<HttpResponseMessage> httpWaitAndRetryPolicy =
Policy.HandleResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode)
.OrHandle<Exception>(r => true)
.WaitAndRetryAsync(10, retryAttempt => TimeSpan.FromSeconds(2));
Run Code Online (Sandbox Code Playgroud)
var serviceProvider = serviceConnection.AddHttpClient(connection.Name, c =>
{
c.BaseAddress = new Uri(connection.BaseUrl);
c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{connection.UserName}:{connection.Password}")));
c.Timeout = connection.Timeout; // Timeout is TimeSpan.FromSeconds(120)
})
.AddPolicyHandler(httpWaitAndRetryPolicy)
.Services.BuildServiceProvider();
HttpClientFactories.Add(connection.Name, serviceProvider.GetService<IHttpClientFactory>());
Run Code Online (Sandbox Code Playgroud)
确认了问题的根本原因:我不知道是什么原因导致了该症状,但看起来请求连接不会被释放,除非显式调用Dispose HttpResponseMessage OnRetry. 当前的解决方案是设置OnRetry并WaitAndRetryAsync配置响应。一切正常,无需更改ServicePointManager.DefaultConnectionLimit