[英]ASP.NET Web API 2 - thrown Exception not in response body in Release mode
In my Web API 2 project, I will do something like this: 在我的Web API 2项目中,我将执行以下操作:
throw new Exception("Error message here.");
In Visual Studio (in Release mode) on my local machine with IIS Express, it properly returns a response with the exception JSON in the body. 在具有IIS Express的本地计算机上的Visual Studio(处于发布模式下)中,它会正确返回正文中带有JSON异常的响应。 But on the production server, it does not. 但是在生产服务器上却没有。 Is there a setting I'm missing somewhere? 我在某处缺少设置吗? Perhaps on the server's IIS? 也许在服务器的IIS上?
You need to update the web.config to get this message when runing ASP.NET at IIS. 在IIS上运行ASP.NET时,需要更新web.config才能获得此消息。
<system.web>
<customErrors mode="Off">
</customErrors>
<!-- Other configurations... -->
</system.web>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.