找不到Microsoft.AspNetCore.Antiforgery [英] Microsoft.AspNetCore.Antiforgery was not found

查看:2385
本文介绍了找不到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:


应用程序依赖项中指定的程序集清单
(website.deps.json)找不到:
包:'Microsoft.AspNetCore.Antiforgery',版本:'2.0.1'
路径:'lib / netstandard2.0 /Microsoft.AspNetCore.Antiforgery.dll'这个程序集是预期的使用以下目标清单文件发布
应用程序时,在本地运行时存储中:
aspnetcore-store-2.0.3.xml

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

根据错误消息,我猜测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网站下载运行时 https://www.microsoft.com/net/download / windows

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆