I've been working on an app and sometimes during my coding I receive 500 Internal Server Error with no content, which isn't really what it's suppose to show. I wrote a code to test the error response in the controller as following:
[HttpGet]
[Route("TryCatch")]
public IHttpActionResult TestCatch()
{
try
{
object obj = null;
int i = (int) obj;
return Ok();
}
catch (Exception e)
{
return InternalServerError(e);
}
}
When I try this locally, I do receive the information regarding the error that I wished for. As for in production, all I see is (in postman) { "message": "An error has occurred." } and the status code.
I've looked around and found what I thought would be solution to my problem: Internal Server Error - Azure App Service Custom Controller but it wasn't.
And adding <httpErrors errorMode="Custom" defaultResponseMode="passThrough">
or <customErrors mode="On"/>
or anything in web.config doesn't help either.
Any help is appreciated!