Using Asp.Net Membership in WCF
I have website that uses ASP.net Membership Provider. This web site will be served by a set of WCF services. I need to extract a profile variable from the user currently calling the service in the service layer. I am using wsHttpBinding and I am following bel开发者_如何学JAVAow MSDN article.
how to use the ASP.NET Membership provider in WCF
Can anyone help me with client settings for this example?
Your client configuration should match the server config:
<configuration>
<system.serviceModel>
...
<bindings>
<wsHttpBinding>
<binding name="MembershipBinding">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
When you connect to your service you need to set the username and password on the client proxy:
client.ClientCredentials.UserName.UserName = "userName";
client.ClientCredentials.UserName.Password = "password";
精彩评论