次の方法で共有


How to turn on debug exceptions with WCF

It is possible to see exceptions passed back in the messages sent to the service.  This makes it a lot easier to debug multi-peer applications.  The way to do this is to add into the web.config file the section.  You can see in the following config section that the behavior <serviceDebug includeExceptionDetailInFaults="true" /> is defined, this sets up the system to include exception details in the return faults. If you do this set this up, make sure you remove it when you deploy your code into the wild. Finding exception info can be used to find ways to exploit your server based on stack traces.

 

    <system.serviceModel>
        <services>
            <service name="OneCareStatus.LogUploadService" behaviorConfiguration="UploadServiceBehavior">
                <endpoint address="" contract="OneCareStatus.ILogUploadService" binding="wsHttpBinding" bindingConfiguration="myHttpBinding"/>
            </service>
            <service name="OneCareStatus.FamilySafetyService" behaviorConfiguration="UploadServiceBehavior">
                <endpoint address="" contract="WpcSettings.IWpcSettingsService" binding="wsHttpBinding" bindingConfiguration="myHttpBinding"/>
            </service>
        </services>
        <bindings>
            <wsHttpBinding>
        <binding name="myHttpBinding">
         <security mode="None" />
         <reliableSession enabled="true"/>
        </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="UploadServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>

Comments

  • Anonymous
    September 14, 2010
    Hello.  I am really hoping you can help me because I am completely lost. So you know, I know very little about .NET, I am a Java developer by trade, but I was asked to help out here and am trying to find any information possible.  The task at hand is simple, we need to get a SharePoint application to authorize either via LDAP or SqlServer authentication.  LDAP works fine, however when trying to validate via SQL we get an exception that isn't very detailed stating that for more detail we need to turn on IncludeExceptionDetailInFaults. I tried following your example, but I am very confused as to how the Bindings work.  Do these need to map to something existing?  Is there a way to set includeExceptionDetailInFaults to true on a global level?  Any information you could provide would be extremely helpful.