IIS 7.5:发送带有自定义错误的http状态代码422 [英] IIS 7.5: sending http status code 422 with custom errors on
问题描述
我在asp.net mvc应用程序中使用自定义操作过滤器,将HTTP状态代码422和验证错误的json列表(基本上是序列化的模型状态字典)返回给客户端,在这里我使用jQuery中的全局ajaxError处理程序进行处理。
I use custom action filter in asp.net mvc app to return http status code 422 and json list of validation errors (basically serialized model state dictionary) to client, where I handle that with global ajaxError handler in jQuery.
所有这些都适用于开发环境,但是我的问题是自定义错误模式处于打开状态(< system.webServer> /< httpErrors errorMode =自定义>
),IIS将响应(json)替换为文本自定义错误模块无法识别此错误。
All of this works on development enviroment, but my problem is when custom errors mode is on (<system.webServer>/<httpErrors errorMode="Custom">
), IIS replaces response (json) with text "The custom error module does not recognize this error."
I' m如果状态代码为422,很难正确配置IIS以传递原始响应。有人做了类似的事情吗?
I'm having hard time properly configuring IIS to pass-through original response if status code is 422. Anyone did something similar?
推荐答案
如果Web服务器配置为通过现有响应,它将json内容返回到浏览器。
If web server is configured to pass through existing response, it will return json contents to browser.
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" existingResponse="PassThrough">
</httpErrors>
</system.webServer>
这篇关于IIS 7.5:发送带有自定义错误的http状态代码422的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!