I’ve been trying to create a WCF service that uses Basic Authentication and so far I keep hitting an error message indicating that the service wants Anonymous authentication even though I thought I'd configured the web.config to use Basic auth.
I spent a few hours trying and failing to find a solution to my problem, so I wanted to give it a try here. I suspect it's something I'm overlooking.
Here's what I'm doing. I created a web project, added a wcf service, created another web project, and added a single .aspx page to test the service. I didn’t change ANYTHING in the default wcf service config. I can deploy to IIS and if I open a browser window and navigate to the page, the service works fine once I enable anonymous authentication. I can also use the test page to access the service without any issues.
Then, I changed the service to use basic auth (see below for the service's web.config) and redeployed. I didn't change IIS's authentication to use Basic, so it was still set to use Anonymous authentication. I refreshed the browser and the service displayed. The test web page was still able to access the service.
Then, I changed the authentication scheme in IIS to use Basic and made sure all other types of authentication were disabled. When I tried to access the service I received the error message, “Security settings for this service require ‘Anonymous’ Authentication but it is not enabled for the IIS application that hosts this service.”
Here is my service’s web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<wsHttpBinding>
<binding name="basicAuthBinding">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="TestService">
<endpoint address="http://localhost:7000/BA.svc" binding="wsHttpBinding" bindingConfiguration="basicAuthBinding" name="BasicEndpoint" />
</service>
</services>
</system.serviceModel>
</configuration>
Any ideas why this isn't working?