gpt4 book ai didi

c# - 我的 Azure 开发环境总是将我重定向到错误页面

转载 作者:行者123 更新时间:2023-12-03 03:55:05 32 4
gpt4 key购买 nike

我有一个本地运行的 MVC 项目,并为其设置了 CI/CD 管道。我遇到的问题是,当我访问服务器时,它总是将我重定向到错误页面。这是我所看到的:

enter image description here

并且 URL 始终添加 aspxerrorpath 参数:

enter image description here

我有自定义错误页面,以下是我的 web.config 文件包含它们的方式:

<customErrors mode="On">
<error statusCode="404" redirect="~/Error/NotFoundError"/>
<error statusCode="500" redirect="~/Error/InternalServerError"/>
</customErrors>

这是我的错误 Controller :

public ActionResult NotFoundError()
{
return View("~/Views/Shared/CustomErrors/_Error404.cshtml");
}

public ActionResult InternalServerError()
{
return View("~/Views/Shared/CustomErrors/_Error500.cshtml");
}

现在,这在本地运行良好;但是,它在 Azure 环境中崩溃了。即使我手动更改网址,它也会在我导航到的所有页面上给出错误。这些页面显示为网络选项卡中的内容302,但我仍然收到此错误。我已尝试以下方法来修复它,但仍然得到相同的结果:

public ActionResult NotFoundError(string aspxerrorpath)
{
if (!string.IsNullOrWhiteSpace(aspxerrorpath))
return RedirectToAction("~/Views/Shared/CustomErrors/_Error404.cshtml");

return View("~/Views/Shared/CustomErrors/_Error404.cshtml");
}

public ActionResult InternalServerError(string aspxerrorpath)
{
if (!string.IsNullOrWhiteSpace(aspxerrorpath))
return RedirectToAction("~/Views/Shared/CustomErrors/_Error404.cshtml");

return View("~/Views/Shared/CustomErrors/_Error500.cshtml");
}

有人可以透露一下正在发生的事情吗?我该如何修复这个错误?

最佳答案

问题在于,当将其部署到我的 Azure AppService 上时,connectionString 密码发生了变化。我需要在构建步骤的 MSBuild 参数中添加 AutoParameterizationWebConfigConnectionStrings 并将其设置为 false,以便它不会标记化

关于c# - 我的 Azure 开发环境总是将我重定向到错误页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64884507/

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