'WCF REST Service works fine on local , gives Unauthorized (401) error on Remote server whereas the service has Anonymous access
I have rambled through net but dint find any solution.
Now The WCF services works perfectly on local whereas on remote server it throws 401 (Unauthorized) web exception for POST calls. GETs work fine.
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.
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.
While calling the caller adds the network credentials.
The header when i call the local network is:
Authorization: Basic dG9ueXXXXXXX
Whereas while calling server :
Authorization: Negotiate TlRMTVNTUAABAAAAl4IIXXXXXXX
This is what is looking fishy for me .
Below given is the Web.config of the Service :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
<add name="SqlServerConnectionString" connectionString="Data Source=BHUVINT\SQL2008R2;Initial Catalog=CPNS;User ID=sa;Password=orion@123"/>
</connectionStrings>
<system.diagnostics>
<trace>
<listeners>
<add name="myListener"
type="System.Diagnostics.EventLogTraceListener"
initializeData="Application" />
</listeners>
</trace>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<machineKey decryption="AES" decryptionKey="0CA3EFAF0F7A5E7A62681C0BF656EE0ECE31ACEE3E1023BA3FAD20EA5F199DE8" validation="SHA1" validationKey="3E4528C0FFE94A75DF02052B358BD9DE40800DD89DE62168764FF0DCE537184F0535D5D9AD66DEDC97DC1ABFF7FA540B4DFD82E5BB196B95D15FF81F75AD5328" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Mg">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.Push">
<endpoint binding="webHttpBinding" name="firstBinding" contract="ApmWcfServiceWebRole.IPushService" />
</service>
<service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.WP7Device">
<endpoint binding="webHttpBinding" name="secondBinding" contract="ApmWcfServiceWebRole.IWP7Service" />
</service>
<service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.iOSDevice">
<endpoint binding="webHttpBinding" name="thirdBinding" contract="ApmWcfServiceWebRole.IIOSService" />
</service>
<service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.AndroidDevice">
<endpoint binding="webHttpBinding" name="fourthBinding" contract="ApmWcfServiceWebRole.IAndroidService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
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.
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.
Thanks in advance.
Solution 1:[1]
The Issue is Solved :
I had enabled Anonymous access , but it had a check enabled on Windows Authentication which i removed and it started working 
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | General Grievance |
