Monday, December 3, 2012

Windows Authentication for WCF service with Silverlight 5, IIS 7.5

Windows Authentication for WCF service with Silverlight 5, IIS 7.5

I have a Silverlight 5 Prism application with a (regular) WCF service in an ASP.net project. I'm using IIS 7.5 to host it on the localhost. I followed all the steps in

How to: Use Windows Authentication to Secure a Service for Silverlight Applications

How to: Host a Secure Service in ASP.NET for Silverlight Applications

but I can't get windows authentication to work. Whenever I turn off anonymous authentication in IIS, my application throws an The remote server returned an error: NotFound. exception because it doesn't find the WCF service.

When I try to update the service reference in Visual Studio I get the error Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

When I turn on Anonymous Authentication the service works, but I don't get the windows user credentials. My browser (IE 8) is set to use integrated windows authentication and automatically logon in the local intranet.

What am I doing wrong?

Here is my IIS 7.5 configuration. The Application pool is running in Integrated mode:

IIS configuration

web.config:

<?xml version="1.0" encoding="UTF-8"?> <configuration>   <system.web>     <compilation debug="true" />     <authentication mode="Windows" />   </system.web>   <system.serviceModel>   <behaviors>     <serviceBehaviors>       <behavior name="">         <serviceMetadata httpGetEnabled="true" />         <serviceDebug includeExceptionDetailInFaults="false" />        </behavior>       </serviceBehaviors>     </behaviors>     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />     </system.serviceModel> </configuration> 

ServiceReferences.ClientConfig:

<configuration>     <system.serviceModel>         <bindings>             <basicHttpBinding>                 <binding name="BasicHttpBinding_ISecurityService" maxBufferSize="2147483647"                     maxReceivedMessageSize="2147483647">                     <security mode="TransportCredentialOnly" />                 </binding>             </basicHttpBinding>         </bindings>         <client>             <endpoint address="http://localhost:85/SecurityService/SecurityService.svc"                 binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISecurityService"                 contract="SecurityServiceReference.ISecurityService" name="BasicHttpBinding_ISecurityService" />         </client>     </system.serviceModel> </configuration> 

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog