2009-04-11 54 views
5

在为我服务的实现,我有:配置WCF表单验证

[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

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

回答

1

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

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

0

我假设你正在检查后续请求上的Identity.Name?

你的web.config中有元素吗?

您是否还要确保从Login响应中捕获cookie并在随后的请求中重新发送它?

1

尝试使用ServiceContext.User.Identity代替。