Reputation: 3
The following is some old ASMX code which I need to convert to WCF service code
Dim cc As New System.Net.CredentialCache
cc.Add(New System.Uri(url), "BASIC", New System.Net.NetworkCredential( _
userName, _
password, _
domain))
And here is my WCF code:
myServiceInstance.Endpoint.Address = New EndpointAddress(url)
Dim credentials As New System.Net.NetworkCredential(userName, password, domain)
myServiceInstance.ClientCredentials.Windows.ClientCredential = credentials
How do I set the AuthenticationType to BASIC in a WCF service?
Upvotes: 0
Views: 142
Reputation: 31630
In your service host you can do this programatically using wsHttpBinding
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Basic;
If you want to do it via config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="UsernameWithTransport">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<!-- Service Details Here -->
</service>
</services>
</system.serviceModel>
</configuration>
Upvotes: 2