简体   繁体   English

ASP.NET Web API 2-在发布模式下不在响应主体中引发异常

[英]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.

相关问题 无法序列化ASP.NET Web API中的响应正文 - Failed to serialize response body in ASP.NET Web API 在ASP.NET Web API C#上使用Regex引发过滤IEnumerable集合的异常 - Exception thrown filtering IEnumerable collection using Regex on ASP.NET Web API C# 如果引发异常,.Net Web API有时会完全不返回任何响应 - .Net Web API returns occasionally no response at all if Exception is thrown 在发布模式下发布 asp.net web 应用程序 - Publish asp.net web app in release mode ASP.NET Web Api中的异常处理2 - Exception Handling in ASP.NET Web Api 2 ASP.NET Web API抛出异常 - ASP.NET Web API Throw Exception 使用 ASP.NET Core 2.2 Web API 项目中的实体框架类库时抛出异常 - Exception thrown when using Entity Framework class library from ASP.NET Core 2.2 Web API project ASP.NET 内核 Web API 使用请求/响应模式处理异常 - ASP.NET Core Web API exception handling with Request/Response Pattern 尝试从asp.net Web API调用获取响应时,Android Studio中出现超时异常 - Timeout exception in android studio while trying to get a response from an asp.net web api call 当动作筛选器创建响应时,未调用ASP.NET Web API异常筛选器 - ASP.NET Web API Exception Filter isn't invoked when Action Filter creates response
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM