Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to diagnose WCF Request errors if I don't have a "<behaviors>" node in my Web.Config?

Tags:

wcf

web-config

Seeing the dreaded Request Error page while testing your WCF Web Service?

enter image description here

Well, worry not, because this StackOverflow answer shows you how to turn on detailed error display: WCF Data Service - How To Diagnose Request Error?

But ... hang on, we don't have a Web.Config that looks anything like that one.

Ours just has a system.serviceModel and that's it.

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
    <standardEndpoints>
        <webHttpEndpoint>
            <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
        </webHttpEndpoint>
    </standardEndpoints>
</system.serviceModel>

If we go for it and simply add the following:

<behaviors>
    <serviceBehaviors>
        <behavior name="DataServiceBehavior">
            <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
    </serviceBehaviors>
</behaviors>

on to the end, then boy is it unhappy:

enter image description here

Update/Edit

Based on answers and comments from @burning_LEGION and @Chris (see below) I now have a Web.Config which looks like this:

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
      <standardEndpoints>
    <webHttpEndpoint>
          <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" behaviorConfiguration="DataServiceBehavior"></standardEndpoint>
    </webHttpEndpoint>
      </standardEndpoints>

      <behaviors>
    <serviceBehaviors>
      <behavior name="DataServiceBehavior">
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
      </behaviors>
  </system.serviceModel>

But I'm getting a Server Error:

Parser Error Message: Unrecognized attribute 'behaviorConfiguration'. Note that attribute names are case-sensitive.

like image 810
hawbsl Avatar asked Feb 19 '23 14:02

hawbsl


2 Answers

Thanks to Chris and burning_Legion for pointing the way. This was the system.serviceModel which I eventually ended up with and which successfully shows the error detail.

It's per @burning_LEGION's answer but without the name attribute on the behavior:

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
      <standardEndpoints>
    <webHttpEndpoint>
          <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
    </webHttpEndpoint>
      </standardEndpoints>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>
like image 170
hawbsl Avatar answered Feb 22 '23 04:02

hawbsl


behaviors must be in tag system.serviceModel

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
    <standardEndpoints>
        <webHttpEndpoint>
            <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
        </webHttpEndpoint>
    </standardEndpoints>   
    <behaviors>
       <serviceBehaviors>
           <behavior name="DataServiceBehavior">
              <serviceDebug includeExceptionDetailInFaults="true"/>
           </behavior>
       </serviceBehaviors>
    </behaviors> 
</system.serviceModel>
like image 34
burning_LEGION Avatar answered Feb 22 '23 03:02

burning_LEGION