Wednesday, 23 January 2013

Minimal web.config for WCF web service in .Net 4.0

Getting correct configuration for running WCF is important, and I am used to mess with ABCs of WCF web service.
I struggled a lot to get this minimal configuration for web.config and finally I got a working solution. Hope this works for everyone.

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
    <authentication mode="Windows"/>
  </system.web>
  <system.serviceModel>
    <bindings>
    </bindings>
    <services>
      <service name="MyProject.Service">
        <endpoint address="" behaviorConfiguration="webHttp" binding="webHttpBinding"
          contract="MyProject.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webHttp">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

No comments:

Post a Comment