Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

c# - Microsoft.AspNetCore.Antiforgery was not found

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.

public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();
}

And in my startup.cs file:

    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure<IISOptions>(options =>
        {
        });
        services.AddMvc();
    }

Yet when I run dotnet website.dll from the command line I get the below error message shown in the command line window:

An assembly specified in the application dependencies manifest (website.deps.json) was not found: package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.1' path: 'lib/netstandard2.0/Microsoft.AspNetCore.Antiforgery.dll' This assembly was expected to be in the local runtime store as the application was published using the following target manifest files: aspnetcore-store-2.0.3.xml

Based off the error message, i'm guessing Microsoft.AspNetCore.Antiforgery isn't being bundled when I publish since I do not receive this error when debugging.

How can I ensure that my app can find Microsoft.AspNetCore.Antiforgery when published to a live environment?

EDIT: This is a basic .net core website. No changes have been made to the standard project at this time apart from the above changes for deployment with IIS.

When I run the project from IIS instead of the command line I get a 502.5 error message.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...