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.
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 having hard time properly configuring IIS to pass-through original response if status code is 422. Anyone did something similar?
Click on "Edit Configuration". Click the Custom Errors tab. Select Off for custom error mode.
To prevent unauthorized users from viewing this privileged information, detailed error pages must not be seen by remote users. This setting can be modified in the errorMode attribute setting for a Web site's error pages. By default, the errorMode attribute is set in the Web.
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>
MSDN: httpErrors Element [IIS Settings Schema]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With