Closed
Description
Hi there,
I have found strange behavior when moved from 3.1 to 5.0.
The same request in the same environment produces a different result.
Runtime: 3.1 - OK
Runtime 5.0.4 - Exception:
An error occurred while sending the request. -> Unable to read data from the transport connection -> An established connection was aborted by the software in your host machine.
Code:
program.cs
namespace WebApplication
{
public class Program
{
public static void Main(string[] args) =>
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(wb => { wb.UseStartup<Startup>(); }).Build().Run();
}
public class Startup
{
public void ConfigureServices(IServiceCollection services){}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
try
{
var client = new HttpClient();
var resp = await client.GetAsync("https://demo.identityserver.io/.well-known/openid-configuration");
await context.Response.WriteAsync(Environment.Version.ToString() + ": " + resp.StatusCode);
}
catch (Exception ex)
{
await context.Response.WriteAsync(Environment.Version.ToString() + ": " + ex.Message);
}
});
});
}
}
}
WebApplication.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<!--<TargetFramework>netcoreapp3.1</TargetFramework>-->
</PropertyGroup>
</Project>
What could be a reason of this behavior on the same machine(just flip TargetFramework)?
Also I have tried on another machine and both runtime works fine and no exception.
OS: Win 10
Thx!