Tip: Remove Stack Trace Information in ASMX (XML) Web Services

By erik at May 26, 2009 13:36
Filed Under: .NET, Architecture

A non-obvious way to alter the behavior of .NET automatically populating Soap fault elements with stack trace information (specifically, in the faultString element) is to use the customErrors configuration element, which is part of the ASP.NET Settings Schema.

I state this is non-obvious because in the documentation, the following statement is made here under the Remarks section:

The <customErrors> element does not apply to errors that occur in XML Web services.

However, the use of this element’s mode attribute clearly does alter the behavior, when setting the mode attribute to “On”, in the system.web configuration section:

<configuration>
    <system.web>
        <customErrors mode="On" />
    </system.web>
</configuration>

Note that the default setting for the customErrors element’s mode attribute is “RemoteOnly” which will add stack trace information for local requests and remove it for remote requests.  This is usually desirable behavior but depending upon your own needs it is good to know the availability of the mode attribute’s “On” setting to always, universally remove the stack trace information, should you desire to do so.

Add comment




  Country flag

biuquote
Loading



Visitors

Disclaimer

Views expressed are my own and in no way represent those of my employer; this is in no way a work or work-related blog.  All postings are presented "AS IS" and confer no rights.

Copyright

All content copyright © 2009-2011 by Erik Mlincek.  You may not use content without the express written consent of the author, however you may link back to blog topics hosted at mlincek.com without obtaining permission in advance.