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

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

问题描述

我正在将一个 asp.net core 2.0 网站部署到 IIS 10.

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

我已确保我的应用在 program.settings 文件中使用了正确的 ISS 配置.

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天全站免登陆