Monthly Archives: February 2014

Unhandled exception in WCF


We will call Business logic layer or DAL through the Web service or WCF if any fault occurs in any layer that uncaught exception will propagate upto service layer, normally at service layer uncaught exception will converted into soap fault exception. Once uncaught exception reaches service layer, it may or may not be exposed to the client, depending upon ‘IncludeExceptionDetailsInFaults’ boolean value which define under the <ServiceBehaviour> section.

By default service won’t share the exception detail with the client since ‘IncludeExceptionDetailsInFaults=False’. This is because if you get any exception in DAL like connection string based exception or any SQL operation error it will directly exposed to client which is not advisable. So when ‘IncludeExceptionDetailsInFaults’ is set to False service general exception information like ‘InternalServiceFault’ will throw to the client, but the exception we received was not very useful.

ServiceDebug

when you want to debug what kind of exception exactly you are getting you can turn on the ‘IncludeExceptionDetailsInFaults’. Once you turn on you can able to
see all kind of exception detail, its stacktrace are also included in the general exception information.

Suppose if you are using ‘wsHttpBinding’ it will use session at that time if you face unhandled exception you can’t use your exception any more, similarly your client
channel also become useless.

EnableViewState=”false” of a page


When I disable ViewState for the page. It does not allow any control in the page to use ViewState even if I set ViewStateMode=”true” property of a control.
This is because I set turn page’s ViewState off, then there is no way for you to enable ViewState for specific components. This is because ViewState is serialized recursively, so when if the Page is not allowing ViewState, it will not serialize the ViewState for any of it’s child controls.