WCF supports sessions, however this requires some security, this link should explain:
http://social.msdn.microsoft.com/Forums/is/wcf/thread/7185e8b7-d4e5-4314-a513-ec590f26ffde
, , . "System.Timers.Timer", - , , , .
, Guid ( ) , reset .
cookie ( ) , cookie :
private string GetCookieValue(string cookieKey)
{
string cookieHeader = WebOperationContext.Current.IncomingRequest.Headers[HttpRequestHeader.Cookie];
string[] cookies = cookieHeader.Split(';');
string result = string.Empty;
bool cookieFound = false;
foreach (string currentCookie in cookies)
{
string cookie = currentCookie.Trim();
string[] cookieKeyValue = cookie.Split('=');
if (cookieKeyValue[0] == cookieKey)
{
result = cookieKeyValue[1];
cookieFound = true;
break;
}
}
if (!cookieFound)
{
string msg = string.Format("Unable to find cookie value for cookie key '{0}'", cookieKey);
throw new KeyNotFoundException(msg);
}
return result;
}
private void SetCookie(string cookie)
{
cookie = cookie + "; path=/;" ;
string currentHeaderValue = WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.SetCookie];
if (!string.IsNullOrEmpty(currentHeaderValue))
{
WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.SetCookie]
= currentHeaderValue + "\r\n" + cookie;
}
else
{
WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.SetCookie] = cookie;
}
}
cookie - "sessionId = {myGuidHere}".
, . , , .
peteski