使用 Web Deploy 在 Azure 中部署普通的 ASP.NET Core 2.2 Web 应用程序引发错误 [英] Deploying a plain ASP.NET Core 2.2 Web App in Azure using Web Deploy is throwing an error

查看:22
本文介绍了使用 Web Deploy 在 Azure 中部署普通的 ASP.NET Core 2.2 Web 应用程序引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 Visual Studio 2017 中的发布屏幕使用 Azure 发布了一个 ASP.NET Core Web 应用程序.我使用了所有默认值,但我的应用程序使用迁移,所以我不得不告诉它在发布配置文件中运行它们.

I went to publish an ASP.NET Core web application using Azure through the Publish screen in Visual Studio 2017. I used all of the defaults, though my app uses migrations so I had to tell it to run them in the publish profile.

然而,当我尝试访问该网站时,我得到:

When I try to access the site, however, I get:

页面无法显示,因为发生了内部服务器错误.

The page cannot be displayed because an internal server error has occurred.

我觉得我需要对连接字符串和 ASPNETCORE_ENVIRONMENT 变量做些什么.

I feel like there is something I need to do with the connection string and the ASPNETCORE_ENVIRONMENT variable.

我仍然拥有您在创建新的 ASP.NET Core Web 应用程序时获得的默认 appsettings.jsonappsettings.Development.json.appsettings.json 指向我的本地开发数据库,​​appsettings.Development.json 指向发布配置文件中的 Azure 数据库.

I still have the default appsettings.json and appsettings.Development.jsonthat you get when creating a new ASP.NET Core web app. The appsettings.json is pointing to my local development database, and the appsettings.Development.json is pointing to the Azure database from the publish profile.

还是发布配置文件会自动处理连接字符串而我不必执行上述任何操作?

Or does the publish profile automatically take care of the connection string and I don't have to do any of the above?

推荐答案

默认情况下,ASP.NET Core 2.2 应用配置为使用新的进程内托管模型.直到 2018 年 12 月的某个时候,它才会在所有地区的 Azure 上可用.他们提到它此处.

By default ASP.NET Core 2.2 apps are configured to use the new In Process hosting model. This will not be available on Azure in all regions until sometime in December 2018. They mention it here.

目前的解决方案是在您的网络应用程序的 .csproj 文件的顶部添加以下内容:

The solution for now is to add the following at the top of your web app's .csproj file:

  <PropertyGroup>
    <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
    <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
  </PropertyGroup>

这篇关于使用 Web Deploy 在 Azure 中部署普通的 ASP.NET Core 2.2 Web 应用程序引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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