我一直在研究一个应用程序,有时在编码过程中,我收到500个没有内容的内部服务器错误,这实际上并不是它显示的内容。我写了一个代码来测试控制器错误响应如下:Azure服务应用程序[Mobileservice] - 自定义错误响应
[HttpGet]
[Route("TryCatch")]
public IHttpActionResult TestCatch()
{
try
{
object obj = null;
int i = (int) obj;
return Ok();
}
catch (Exception e)
{
return InternalServerError(e);
}
}
当我尝试这个地方,我也收到有关,我希望该错误的信息。至于在制作中,我所看到的只是(在邮差中){“message”:“发生错误。” }和状态码。
我环顾四周,发现我认为会解决我的问题:Internal Server Error - Azure App Service Custom Controller但事实并非如此。
并添加<httpErrors errorMode="Custom" defaultResponseMode="passThrough">
或<customErrors mode="On"/>
或web.config中的任何内容都无济于事。
任何帮助表示赞赏!
谢谢先生! 'config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;'那部分解决了我的问题! –