I have a WCF service with following configuration:
<service behaviorConfiguration="MyServiceBehavior" name="Service1">
<endpoint address=""
binding="wsHttpBinding" bindingConfiguration="MembershipBinding"
name="ASPmemberUserName" contract="TestWcfService.IService1" />
</service>
.
.
.
.
.
<wsHttpBinding>
<binding name="MembershipBinding">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
I want to pass the username to the service proxy on client and retrieve it on the server side. I use bellow code to pass the user name to the proxy class:
Service1Client sc = new Service1Client();
sc.ClientCredentials.UserName.UserName = HttpContext.Current.User.Identity.Name;
When I try to retrieve the username on the server, the ServiceSecurityContext.Current
returns null. Any ideas why it acts like this?
The problem was caused by certificate settings. Below link helped solve the issue:
A simple WCF service with username password authentication: the things they don't tell you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.