WCF FaultException Without Sending StackTrace
Asked Answered
H

1

8

I have some WCF services with predefined FaultContract attributes. When the FaultException<TDetail> exceptions are thrown, they're sending StackTrace, Source and other potentially unsave information.

Is it possible to return only:

  • Detail (from the generic TDetail)
  • FaultMessage
  • FaultCode
  • (and possibly) FaultReason
Hendecasyllable answered 28/10, 2010 at 19:9 Comment(0)
A
3

Have you tried rolling your own fault exception using IErrorHandler? Also make sure in your app config file, the IncludeExceptionDetailInFaults attribute is set to false and, this might be helpful for best pratices.

Acromion answered 28/10, 2010 at 19:52 Comment(4)
IncludeExceptionDetailInFaults is already false. As I understand it, IncludeExceptionDetailInFaults only applies to unhandled exceptions that are not already of type FaultException<TDetail>. I already implemented an IErrorHandler in order to enforce a policy that all operations have a base FaultContract assigned and that automatically logs and rethrows unhandled exceptions in that base fault type.What I don't know is why WCF is passing more information than is defined in the FaultContract. I'm currently experiencing this behavior with wsHttpBinding and a SOAP client.Hendecasyllable
It turns out that there wasn't a problem with StackTrace being sent back to the client. (The problem was in front of the keyboard.) I was misinterpreting the response received from WCFStorm in the Response pane. The stacktrace and source were only information about the client and not the server. IncludeExceptionDetailInFaults definitely only applied to exceptions that are not "well known" though. Thanks for the help Terrance.Hendecasyllable
Thanks for following up on this @reifnir, you saved me from potentially a lot of wasted time trying to figure out how to prevent this!Vibrations
Yeah, that's confusing, especially because even with IncludeExceptionDetailInFaults=false, the stack trace says "Server stack trace: ..." although in reality it's the client stack trace only.Denominational

© 2022 - 2024 — McMap. All rights reserved.