Skip to content

NetFramework 4.6.1 to 4.8 with System.Net.Http regression #65005

Closed
@ladeak

Description

@ladeak

Description

I have been updating a .net framework 461 application to net48. In the medium future to updating to net6.0 as well, currently many projects are already multi-targeted.

Due to nuget package dependencies in the net461 build System.Net.Http.dll with AssemblyVersion 4.2.0.0 is placed in the output folder and being used at runtime. I also have a corresponding binding redirect in web.config file.

After switching to net48, I have to add a reference

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
     <Reference Include="System.Net.Http" />
</ItemGroup>

to the csproj to get things compile. I also have to remove the assembly binding redirect in the web.config. In the new compilation, System.Net.Http.dll is not placed in the output folder, during runtime it is picked up from the GAC with version 4.1.x.x. This is a version downgrade, which has regression:

HttpClient does not dispose the request content in 4.2.0.0 or net6.0, but in net48, it calls dispose

I would like to keep the 4.2.0.0 behavior, because that matches with net6.0. Adding System.Net.Http as a nuget package is not an option, as those versions have this regression too.

What are the options to keep the net461/net6.0 behavior of System.Net.Http with net48?

Reproduction Steps

  • Create a net461 asp.net application.
  • Add nuget package which brings a transitive dependency on System.Net.Http. During runtime version 4.2.0.0 is used.
  • Update the application to net48.
  • An older version of System.Net.Http is being used at runtime.

Expected behavior

I would like to have the same behavior as in net461 which stands closer to net6.0, while net48 has a regression in this sense.

I would expect HttpClient not to dispose the request's HttpContent in net48.

Actual behavior

HttpClient disposes the request's HttpContent in net48.

Regression?

Yes, it seems so.

Known Workarounds

No known workarounds.

Configuration

  • net461, net48, net6.0
  • Windows Server 2019
  • x64
  • Visual Studio 2022

Other information

I understand why the dll is picked up from the GAC related to net48 being netstanard2.0 compatible. How can I "override" this net48 behavior anad keep the one I experience in net461?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions