developers.de
daenet's .NET Community

WCF Service:The remote server returned an error: (401) Unauthorized.

Damir Dobric Posts

 

Damir@Phone    



My upcoming sessions:

AppFabric Applications at
NRW Conf 2011
09.Sept.2011 Wuppertal

HTML5 widgets in WP7+
Monodroid
Mobility Day
21.Sept.2011 - Zagreb

AppFabric and WCF sessions at
Advanced Developer Conference
26.-27. Oktober 2011 in Frankenthal

AppFabric Applications, queues, topics and more at
Prio Conference
02. - 03. November 2011 in Meistersingerhalle Nürnberg

AppFabric Applications deep dive hosted by
.NET User Group Frankfurt
17.Nov.2011 18.30-22.30 Microsoft - Bad Homburg 

 

 

 

By connecting to WCF WebService with configuration shown bellow you may notice that the client could get sometimes in trouble.
That is the exception can be thrown while invoking of some service operation: The remote server returned an error: (401) Unauthorized.

<endpoint address="basiccredentialsendpoint"
                binding="basicHttpBinding"
                bindingConfiguration="BasicAuthenticationBinding"
                contract="IService"/>

 

If authentication settings of the service in IIS looks like shown at the picture below, you will get the error shown above.

image
If you for example disable the WindowsAuthentication, the client will authenticate successfully by using of
Basic-Transport-Authentication.

image

However if you enable BasicAuthetication in IIS only but you enable both in WCF
you will also get an error: InternalServer Error 500: Client found response content type of '', but expected 'text/xml'.

 

<endpoint address="windowscredentialsendpoint"
                binding="basicHttpBinding"
                bindingConfiguration="WindowsCredentialsViaTransport"
                contract="IService"/>

<endpoint address="basiccredentialsendpoint"
                binding="basicHttpBinding"
                bindingConfiguration="BasicAuthenticationBinding"
                contract="IService"/>

Posted Jul 06 2009, 06:47 PM by Damir Dobric

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
daenet GmbH