[英]How to WebDeploy an ASP.NET Core application in “Production” environment?
I created a test ASP.NET Core web app and published it to azure via Web Deploy... 我创建了一个测试ASP.NET Core Web应用程序,并通过Web Deploy将其发布为Azure。
When I try to access a page controller via the site URL, I have the following: 当我尝试通过站点URL访问页面控制器时,出现以下情况:
I have mainly non-modified by default 我主要是默认情况下未修改
also a
lauchSettings.json
file with 还有一个
lauchSettings.json
文件,
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:23403/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express (Staging)": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Staging"
}
},
"IIS Express (Production)": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
},
"MyApplication": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:23404"
}
}
}
What should I do in order to modify the ASPNETCORE_ENVIRONMENT variable when publishing it via 通过发布时如何修改ASPNETCORE_ENVIRONMENT变量
PS. PS。
I updated the App Settings in Azure portal, like this 我像这样更新了Azure门户中的应用程序设置
then republished the application...
然后重新发布该应用程序...
But nothing changed, I have the same Error ... 但是什么都没有改变,我有同样的错误 ...
launchsettings.json only affects local development I think. launchsettings.json仅影响本地开发。 It won't affect it in Azure.
在Azure中不会影响它。 I think you should be able to define an app setting with key
ASPNETCORE_ENVIRONMENT
set to eg Development. 我认为您应该能够将
ASPNETCORE_ENVIRONMENT
键设置为“开发”来定义应用程序设置。
I thinks you are mixing 2 questions here. 我认为您在这里混了2个问题。
As about deployment, it looks like you did everything correctly - your site is hosted using not Development environment. 关于部署,您似乎正确完成了所有操作-您的网站不是使用开发环境托管的。 This is exactly what error page tells you.
这正是错误页面告诉您的内容。
As about bugs, you definitely would not like anyone to see your connection strings or anything else an error message may contain. 关于错误,您绝对不希望任何人看到您的连接字符串或错误消息可能包含的其他任何内容。 So you need to add some logging to see what really fails.
因此,您需要添加一些日志记录以查看真正失败的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.