How to Stop IIS Using Error Codes for Soap Errors

We provide a web service to a third party that expects 500 errors when an application-level error occurs. When this happens, we build a piece of custom XML with error data (eventcode, etc.) and return it as a synchronous response.

However, it seems that IIS is catching the 500 error and replacing our custom XML with a “beautiful” html page.

Does anyone know how I can stop this? We tried to disable user errors in IIS, and all we will return to this setting is the error line and now our custom XML.

Notes: IIS version 7 (Windows Server 2008) with a custom handler that we developed last week.

+3
source share
1 answer

Answer: - use HttpResponse.TrySkipIisCustomErrors

That's what we do, something like this.

httpApplication.Response.ContentType = "text/xml";
httpApplication.Response.Write(myCustomErrorString);
httpApplication.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
httpApplication.Response.TrySkipIisCustomErrors = true;

Thanks Rick Strahl

+1
source

Source: https://habr.com/ru/post/1771760/


All Articles