1

I have an MVC project running locally, and I set-up CI/CD pipelines for it. The issue I am having is that when I go on the server, it always redirects me to an error page. Here is what I am seeing on my end:

enter image description here

and the URL always adds a aspxerrorpath parameter:

enter image description here

I have custom error pages in place, and here is how my web.config file has them:

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

and here is my error controller:

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

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

Now, this runs fine locally; however, it breaks on the Azure environment. Even when I manually change the url, it gives the error on all the pages I navigate to. The pages show as found in the network tab,302, but I still get this error. I have tried the following to fix it but still got the same result:

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

Can someone shed some light on what is going on? How can I fix this error?

developer
  • 35
  • 3

1 Answers1

0

The issue was that the connectionString password was changing when it gets deployed on my Azure AppService. I needed to add the AutoParameterizationWebConfigConnectionStrings in my MSBuild Arguments in the build step and set it to false so that it won't tokenize

developer
  • 35
  • 3