我的 Web Api 在本地运行时(在发布模式下)将返回以下格式的任何错误:
{
"Message": "An error has occurred.",
"ExceptionMessage": "No text specified",
"ExceptionType": "System.Exception",
"StackTrace": null
}
但在部署/发布到 Azure VM 后,只剩下以下内容:
{
"Message": "An error has occurred."
}
API 代码:
try
{
var msg = ...
new MessageService().SaveMessage(msg)); // <-- does some checks; may throw.
return Ok();
}
catch (Exception ex)
{
return InternalServerError(ex);
}
我希望它在 Azure 上更详细,例如本地结果。
这可以实现吗?如果可以,如何实现?
我已经(暂时)删除了<compilation xdt:Transform="RemoveAttributes(debug)" />
来自<system.web>
Web.Release.config 的一部分,然后重新部署,但这没有什么区别。
或者我使用了错误的方法/模式?
显然技术细节应该是有限的,但现在我们根本没有得到任何细节。
您可以尝试将以下内容添加到 Global.asax 中:
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
注意:我不建议您在生产环境中保留此设置。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)