gpt4 book ai didi

asp.net - 尝试访问 Azure Web 应用程序中的特定页面时发生错误

转载 作者:行者123 更新时间:2023-12-02 07:03:28 26 4
gpt4 key购买 nike

我是 ASP.NET 的新手。我一直在关注this ASP.NET Razor pages教程并将我的应用程序部署到 Azure。

但是当我尝试访问this Movies时页面,我收到此错误。

Error.

An error occurred while processing your request.

Request ID: | f9ecac03-478613f8cb88adc0.

Development Mode Swapping to the Development environment displays detailed information about the error that occurred.

The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end-users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app.

我已经尝试过this existing solution并更改为生产模式,但问题仍然存在。

这是我的启动设置 -

{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:50335",
"sslPort": 44327
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
},
"Polling_System": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
}
}
}

我的部署模式是依赖框架,后来我将其更改为自包含

谁能帮我解决这个问题吗?谢谢。

P.S. 如果 "ASPNETCORE_ENVIRONMENT": 的值设置为 "Development",则该页面可以在我的计算机上正常运行

最佳答案

更新:

这是标准的网络配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\OurWebApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>

解决方案:

添加或更改 web.config 的 ASPNETCORE_ENVIRONMENT 设置。

正如错误所示,

The Development environment shouldn't be enabled for deployed applications.

所以请将其更改为其他环境。对不起。刚才回答错了。

看看这个:

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1#environments

在 Web.config 中添加这些代码或更改 webconfig 中的值。(在 Kudu 上的 site/wwwroot 下):

<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="[Other env instead of Development]" />
</environmentVariables>

您的 Kudu 页面应为:https://[yourwebsitename].scm.azurewebsites.net/DebugConsole

(将[yourwebsitename]更改为您的网站名称,然后您将转到kudu)

不要忘记保存编辑。这应该无需重新启动即可工作。

关于asp.net - 尝试访问 Azure Web 应用程序中的特定页面时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59844813/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com