首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF UserName clientCredentialType

WCF UserName clientCredentialType
EN

Stack Overflow用户
提问于 2011-03-28 16:43:53
回答 1查看 9K关注 0票数 0

我有一个WCF服务,配置如下:

代码语言:javascript
复制
        <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>

我希望将用户名传递给客户端的服务代理,并在服务器端检索它。我使用下面的代码将用户名传递给代理类:

代码语言:javascript
复制
Service1Client sc = new Service1Client();

sc.ClientCredentials.UserName.UserName = HttpContext.Current.User.Identity.Name;

当我尝试检索服务器上的用户名时,ServiceSecurityContext.Current返回null。你知道为什么它是这样的吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-28 21:08:27

该问题是由证书设置引起的。下面的链接帮助解决了这个问题:

A simple WCF service with username password authentication: the things they don’t tell you

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5456538

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档