How To Enable Stack Trace in WCF? | WCF Interview Question

, ,
The service model returns a generic SOAP fault to the client which does not include any exception specific details by default. However, an exception details in SOAP faults can be included using IncludeExceptionDetailsInFaults attribute. If IncludeExceptionDetailsInFaults is enabled, exception details including stack trace are included in the generated SOAP fault. IncludeExceptionDetailsInFaults should be enabled for debugging purposes only. Sending stack trace details is risky.

IncludeExceptionDetailsInFaults can be enabled in the web.config file :-

<behaviors>
 <serviceBehaviors>
  <behavior name="ServiceGatewayBehavior">
   <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
   <serviceMetadata httpGetEnabled="true"/>
   <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
   <serviceDebug includeExceptionDetailInFaults="true"/>
  </behavior>
 </serviceBehaviors>
</behaviors>