Microsoft.AspNetCore.Antiforgery was not found

I was able to fix this issue by updating the .net core runtime on the server to v2.0.3.

This issue occurs if

  1. You have an existing server running v2.0.0 of the .net core runtime.
  2. You create an app targeting v2.0.3 of the SDK
  3. You publish the v2.0.3 app to a server running v2.0.0

The issue can be resolved by installing v2.0.3 of the runtime on the server. You can download the runtime from the microsoft site here https://www.microsoft.com/net/download/windows


If you are actually using this library, make sure that your *.csproj file has the corresponding explicit reference:

<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="..." />

Then, play with the PublishWithAspNetCoreTargetManifest property to resolve the aforementioned issue with a mismatched manifest. Check out the following threads to learn more about possible issues while its deployment:

An assembly specified in the application dependencies manifest (RhWeb.deps.json) was not found

published application is missing assembly (missing runtime store associated ...) [2.0.0-preview2-005905]

HTTP Error 502.5 - Microsoft.AspNetCore.Antiforgery.dll


I had this issue - simple workaround, actually install the NuGet package (I wasn't using it).

Microsoft.AspNetCore.Antiforgery

Published, deployed - fixed the issue.

In another case, when I published the project, a lot of the dlls weren't being placed in the publish folder - including Antiforgery. The below appears to force publishing to add all the required dlls.

Edit your projectname.json file to ensure PropertyGroup contains PublishWithAspNetCoreTargetManifest = false:

<PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

Interested to know why the above works?!