即使将IncludeErrorDetailPolicy设置为Always,我也没有看到错误详细信息
我在Startup.cs中有以下代码。
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always
我还有什么需要做的吗?我可以在本地计算机上获取全部错误信息,但在部署DEV服务器后无法在DEV服务器中获取。
我登录到服务器,并将customError模式设置为“开”。另外,我将httpErrors设置为“ Detailed”。
<system.web>
<customErrors mode="On"/>
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed"/>
</system.webServer>
在这些更改之后,它也没有显示。在IIS中还有什么需要做的吗?
首先,这不是答案。这是一种解决方法:
我从Startup.cs中删除了以下代码
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always
在system.webServer部分的web.config中添加了以下内容:
<httpErrors existingResponse="PassThrough" errorMode="Detailed" />
另外,我使用ResponseMessage(HttpResponseMessage)
而不是InternalServerError(Exception)
如下所示:
private IHttpActionResult CustomHttpActionResult(string message)
{
return ResponseMessage(new HttpResponseMessage
{
Content = new StringContent(message),
StatusCode = HttpStatusCode.InternalServerError
});
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句