Deploying a plain ASP.NET Core 2.2 Web App in Azure using Web Deploy is throwing an error(使用 Web Deploy 在 Azure 中部署普通的 ASP.NET Core 2.2 Web 应用程序会引发错误)
问题描述
我通过 Visual Studio 2017 中的 Publish 屏幕使用 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.json 和 appsettings.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.
目前的解决方案是在 Web 应用的 .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 应用程序会引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Web Deploy 在 Azure 中部署普通的 ASP.NET Core 2.2 Web 应用程序会引发错误
基础教程推荐
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 将数据集转换为列表 2022-01-01
- 如果条件可以为空 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
