2009-04-11 59 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代替。