我有一个WCF服务,配置如下:
<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>
我希望将用户名传递给客户端的服务代理,并在服务器端检索它。我使用下面的代码将用户名传递给代理类:
Service1Client sc = new Service1Client();
sc.ClientCredentials.UserName.UserName = HttpContext.Current.User.Identity.Name;当我尝试检索服务器上的用户名时,ServiceSecurityContext.Current返回null。你知道为什么它是这样的吗?
发布于 2011-03-28 21:08:27
该问题是由证书设置引起的。下面的链接帮助解决了这个问题:
A simple WCF service with username password authentication: the things they don’t tell you
https://stackoverflow.com/questions/5456538
复制相似问题