1
在我的wcf項目中,我們希望在使用asp.net會話時存儲一些用戶信息(userid或其他)。登錄後,userid將存儲在會話 中,我們可以檢索它其他服務。我發現我們可以在wcf中使用httpcontext.current.session,但只支持在IIS中託管的wcf。 我的wcf服務將託管在窗口service.Is有什麼辦法可以做? wcf中是否有變量或函數來獲取這些特徵? 請指導我正確的方式。謝謝你的幫助。WCF服務中的會話使用
//For example
//LogOnWCFService
public Boolean LogOn(string userID, string PWD)
{
currentUserID = userID;
HttpContext.Current.Session.Add("UserID",userID);
return true;
}
//ProcessWCFService
public void Process()
{
string userid = HttpContext.Current.Session["UserID"].ToString();
if(userid == 1)
{
//Do Something
}
}