【问题标题】:My Azure dev environment always redirects me to an error page我的 Azure 开发环境总是将我重定向到错误页面
【发布时间】:2021-03-01 05:09:54
【问题描述】:

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

并且 URL 总是添加一个aspxerrorpath 参数:

我有自定义错误页面,下面是我的 web.config 文件的内容:

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

这是我的错误控制器:

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");
  }

有人能解释一下发生了什么吗?我该如何解决这个错误?

【问题讨论】:

  • 如果您需要进一步的帮助,请告诉我。

标签: c# asp.net-mvc azure azure-pipelines


【解决方案1】:

问题是在我的 Azure AppService 上部署时,connectionString 密码正在更改。我需要在构建步骤中的 MSBuild Arguments 中添加 AutoParameterizationWebConfigConnectionStrings 并将其设置为 false 以便它不会标记化

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-10
    • 1970-01-01
    • 2013-04-18
    • 2020-04-24
    • 1970-01-01
    • 2020-11-13
    • 2012-01-03
    • 2023-03-24
    相关资源
    最近更新 更多