我正在使用 Open Rasta 和 ASP.NET 为某种问题跟踪器构建一个演示 API,并将其部署到 Windows Azure Web 应用程序。
API 以专用媒体类型 (application/mason+json) 返回详细的错误信息。在我的本地计算机上,我得到了预期的错误响应,但在 Azure 上,我只得到错误代码(例如 404)和标准 ASP.NET 错误消息。
例如参见 http://mason-issue-tracker.azurewebsites.net/projects/999它应该返回 application/mason+json 但返回 HTML。
Azure 中是否有某个设置可以更改此设置?
最佳答案
web.config 中缺少的设置是这样的:
<system.webServer>
<httpErrors existingResponse="PassThrough"></httpErrors>
</system.webServer>
这为我解决了这个问题。我仍然不知道为什么 Azure 上需要它,但我的本地计算机上不需要。
在 http://develoq.net/2011/returning-a-body-content-with-400-http-status-code/ 找到答案。该设置记录在 https://msdn.microsoft.com/en-us/library/ms690497%28VS.90%29.aspx
关于asp.net - 如何在 Windows Azure Web App 上配置错误响应格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30636956/