title: WCF REST Service works fine on local , gives Unauthorized (401) error on Remote server whereas the service has Anonymous access
body: <p>I have rambled through net but dint find any solution.
  <br>
  Now The WCF services works perfectly on local whereas on remote server it throws 401 (Unauthorized) web exception for POST calls. GETs work fine.</p>
  
  <pre><code>Implementation Details :
  On the Remote Server-
      IIS : 6.0
      .NET : 4.0
      Calling App : WPF app.
  
  On the Local Server-
      IIS : 7.0
      .NET : 4.0
      Calling App : WPF app.
  </code></pre>
  
  <p>The service has Anonymous access specified for the WCF rest in the web.config.
  For authentication We have implemented a AuthManager class which authenticates the request using hardcoded usernames and passwords. </p>
  
  <p>While calling the caller adds the network credentials.</p>
  
  <p>The header when i call the local network is:</p>
  
  <pre><code>Authorization: Basic dG9ueXXXXXXX
  </code></pre>
  
  <p>Whereas while calling server :</p>
  
  <pre><code>Authorization: Negotiate TlRMTVNTUAABAAAAl4IIXXXXXXX
  </code></pre>
  
  <p>This is what is looking fishy  for me . </p>
  
  <p>Below given is the Web.config of the Service : </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="SqlServerConnectionString" connectionString="Data Source=BHUVINT\SQL2008R2;Initial Catalog=CPNS;User ID=sa;Password=orion@123"/&gt;
    &lt;/connectionStrings&gt;
    &lt;system.diagnostics&gt;
      &lt;trace&gt;
        &lt;listeners&gt;
          &lt;add name="myListener"
                       type="System.Diagnostics.EventLogTraceListener"
               initializeData="Application" /&gt;
        &lt;/listeners&gt;
      &lt;/trace&gt;
    &lt;/system.diagnostics&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
      &lt;machineKey decryption="AES" decryptionKey="0CA3EFAF0F7A5E7A62681C0BF656EE0ECE31ACEE3E1023BA3FAD20EA5F199DE8" validation="SHA1" validationKey="3E4528C0FFE94A75DF02052B358BD9DE40800DD89DE62168764FF0DCE537184F0535D5D9AD66DEDC97DC1ABFF7FA540B4DFD82E5BB196B95D15FF81F75AD5328" /&gt;
    &lt;/system.web&gt;
  
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="Mg"&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
          &lt;/behavior&gt;
          &lt;behavior name=""&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.Push"&gt;
          &lt;endpoint binding="webHttpBinding" name="firstBinding" contract="ApmWcfServiceWebRole.IPushService" /&gt;
        &lt;/service&gt;
        &lt;service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.WP7Device"&gt;
          &lt;endpoint binding="webHttpBinding" name="secondBinding" contract="ApmWcfServiceWebRole.IWP7Service" /&gt;
        &lt;/service&gt;
        &lt;service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.iOSDevice"&gt;
          &lt;endpoint binding="webHttpBinding" name="thirdBinding" contract="ApmWcfServiceWebRole.IIOSService" /&gt;
        &lt;/service&gt;
        &lt;service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.AndroidDevice"&gt;
          &lt;endpoint binding="webHttpBinding" name="fourthBinding" contract="ApmWcfServiceWebRole.IAndroidService" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true"&gt;
      &lt;/serviceHostingEnvironment&gt;
  
    &lt;/system.serviceModel&gt;
  
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true" /&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>EDIT :
  The AuthManager is called only wherein the POSTs are being made wherein the checks are required , And these are the ones which are failing.</strong></p>
  
  <p><strong>EDIT 2:
  I added a Trace in the AuthManager , The credentials are not received by it , its getting a blank value. Seems the issue is with passing credentials.</strong></p>
  
  <p>Thanks in advance.</p>