本文介绍了找不到Microsoft.AspNetCore.Antiforgery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向IIS 10部署一个asp.net核心2.0网站。

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

我确保我的应用程序正在使用正确的ISS配置program.settings文件。

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();
}

在我的startup.cs文件中:

And in my startup.cs file:

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

然而,当我从命令行运行dotnet website.dll时,我得到以下内容命令行窗口中显示的错误消息:

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

根据错误消息,我猜测Microsoft.AspNetCore.Antiforgery在发布时没有捆绑,因为我在调试时没有收到此错误。

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.

如何确保我的应用在发布到实时环境时能够找到Microsoft.AspNetCore.Antiforgery?

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

编辑:这是一个基本的.net核心网站。除了上面使用IIS进行部署的更改之外,此时没有对标准项目进行任何更改。

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.

当我从IIS而不是命令行运行项目时得到一条502.5错误消息。

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

推荐答案

我能够通过将服务器上的.net核心运行时更新为v2来解决此问题.0.3。

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

如果


  1. 您的现有服务器正在运行,则会出现此问题.net核心运行时的v2.0.0。

  2. 您创建了一个针对SDK v2.0.3的应用程序

  3. 您发布了v2.0.3应用程序运行v2.0.0的服务器

可以通过在服务器上安装运行时的v2.0.3来解决该问题。您可以从Microsoft网站下载运行时

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

这篇关于找不到Microsoft.AspNetCore.Antiforgery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 20:40