Microsoft.AspNetCore.Antiforgery was not found

后端 未结 7 2038
终归单人心
终归单人心 2020-12-20 12:48

I\'m deploying a asp.net core 2.0 website to IIS 10.

I\'ve made sure that my app is using the correct configuration for ISS in the program.settings file.

<         


        
相关标签:
7条回答
  • 2020-12-20 13:07

    I fixed this issue on my inhouse windowsserver with this solution
    * go to netcore https://github.com/dotnet/core/tree/master/release-notes
    * go to the lastest version of the core runtime 2.?
    * download DotNetCore.2.0.6-WindowsHosting.exe in my case
    https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.6-download.md#net-core-runtime-only-installation

    Install this on server and the error was solved for me. Hope this helps anyone.

    0 讨论(0)
  • 2020-12-20 13:11

    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

    0 讨论(0)
  • 2020-12-20 13:13

    Got this error after updating Microsoft.AspNetCore.All from v2.0.7 to v2.0.8 (latest at the time) and then publishing to a server that was running .NET Core Runtime v2.0.7 (latest at the time).

    Downgraded Microsoft.AspNetCore.All back down to v2.0.7, re-published, and everything works.

    0 讨论(0)
  • 2020-12-20 13:15

    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?!

    0 讨论(0)
  • 2020-12-20 13:27

    If you publish the app as a self-contained ASP.NET Core 2.2 apps as per the linked screenshot (I don't have enough rep for inline image), it will fix this issue.

    Self contained: Screenshot

    This can be set when editing your publish settings.

    0 讨论(0)
  • 2020-12-20 13:28

    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

    0 讨论(0)
提交回复
热议问题