配置WCF表单身份验证

时间:2009-04-11 17:10:01

标签: wcf forms-authentication

在我的服务实施中,我有:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

在我的.config文件中,我有:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

  <system.web.extensions>
    <scripting>
      <webServices>
        <authenticationService enabled="true" requireSSL = "false"/>
      </webServices>
    </scripting>
  </system.web.extensions>

<authentication mode="Forms" />

在我的服务的“登录”方法中,我有:

FormsAuthentication.SetAuthCookie(request.UserName, false);

然而,当我检查时:

HttpContext.Current.User.Identity.Name

这是一个空字符串。我错过了什么?

3 个答案:

答案 0 :(得分:1)

当您希望用户填写登录表单时,将使用表单身份验证。

对于服务,最好使用不同的身份验证机制。

答案 1 :(得分:1)

请尝试使用ServiceContext.User.Identity。

答案 2 :(得分:0)

我假设您在后续请求中检查Identity.Name?

你的web.config中有一个元素吗?

您是否确保从登录响应中捕获cookie并在后续请求中重新发送?

相关问题