How do I stop IIS mangling my error codes for Soap faults
We provide a webservice to a third-party that expects a 500 error when an application level error occurs. When this happens we construct a piece of custom XML with the error details (eventcode etc) and return this as the synchronous response.
However, it seems that开发者_StackOverflow中文版 IIS is intercepting the 500 error and replacing our custom XML with a "pretty" html page.
Does anybody know how I can stop this from happening? We have tried disabling custom errors in IIS and all we get back in that setup is a "an error occurred" string and now our custom XML.
Notes: IIS version 7 (Windows Server 2008) with a custom Handler we developed last week.
Answer: is to use HttpResponse.TrySkipIisCustomErrors
Here's what we're doing, something like this..
httpApplication.Response.ContentType = "text/xml";
httpApplication.Response.Write(myCustomErrorString);
httpApplication.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
httpApplication.Response.TrySkipIisCustomErrors = true;
Thanks to Rick Strahl
精彩评论