Search code examples
asp.net-mvcazureinternal-server-error

Internal Server Error being returned from ASP.NET MVC Action in Azure App Service Plan


I'm hosting an ASP.NET MVC 4.6.2 application in Microsoft Azure in an App Service Plan and using it purely as an API (that is, I'm not using WebAPI but using standard Controllers and Actions as my API for a web UI that lives in a different project).

Everything was working fine until I started getting a generic 500 Internal Server Error returned from one of my Actions (also, all actions are configured to return JSON). Other Actions work fine.

I have Rollbar setup to log all Application exceptions and nothing was being reported.

What was causing this error?


Solution

  • A big clue was Rollbar exceptions being logged, therefore it was happening earlier in the pipeline before my application code was being executed.

    I used the Postman extension for Chrome to test submitting to the API and it worked fine.

    Thinking for a moment I concluded and confirmed that the AJAX request data being POSTed from the UI didn't conform to the method signature of the Action I was submitting to. In fact, it was a login form and I had incorrectly configured my front-end code to pass a text 'rememeber-me' to my boolean 'RememberMe' parameter instead of a true/false value. Fixing this fixed the issue.

    What I need to investigate now is how to effectively produce details logs and alerts on this type of exception in production.