Skip to main content

SessionExtensions

Configure ServiceStack to have ISession support

Assembly: ServiceStack.dll
View Source
Declaration
public static class SessionExtensions

Methods

GetOrCreateSessionId(IRequest)

View Source
Declaration
public static string GetOrCreateSessionId(this IRequest httpReq)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

SetSessionId(IRequest, String)

View Source
Declaration
public static void SetSessionId(this IRequest req, string sessionId)
Parameters
TypeName
ServiceStack.Web.IRequestreq
System.StringsessionId

GetSessionId(IRequest)

View Source
Declaration
public static string GetSessionId(this IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetPermanentSessionId(IRequest)

View Source
Declaration
public static string GetPermanentSessionId(this IRequest httpReq)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

GetTemporarySessionId(IRequest)

View Source
Declaration
public static string GetTemporarySessionId(this IRequest httpReq)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

GetSessionParam(IRequest, String)

View Source
Declaration
public static string GetSessionParam(this IRequest httpReq, string sessionKey)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
System.StringsessionKey

CreateSessionId(IResponse, IRequest)

Create the active Session or Permanent Session Id cookie.

View Source
Declaration
public static string CreateSessionId(this IResponse res, IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IResponseres
ServiceStack.Web.IRequestreq

CreateSessionIds(IResponse, IRequest)

Create both Permanent and Session Id cookies and return the active sessionId

View Source
Declaration
public static string CreateSessionIds(this IResponse res, IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IResponseres
ServiceStack.Web.IRequestreq

CreateRandomSessionId()

View Source
Declaration
public static string CreateRandomSessionId()
Returns

System.String

PopulateWithSecureRandomBytes(Byte[])

View Source
Declaration
public static void PopulateWithSecureRandomBytes(byte[] bytes)
Parameters
TypeName
System.Byte[]bytes

CreateRandomBase64Id(Int32)

View Source
Declaration
public static string CreateRandomBase64Id(int size = 15)
Returns

System.String

Parameters
TypeName
System.Int32size

CreateRandomBase62Id(Int32)

View Source
Declaration
public static string CreateRandomBase62Id(int size)
Returns

System.String

Parameters
TypeName
System.Int32size

Base64StringContainsUrlUnfriendlyChars(String)

View Source
Declaration
public static bool Base64StringContainsUrlUnfriendlyChars(string base64)
Returns

System.Boolean

Parameters
TypeName
System.Stringbase64

CreatePermanentSessionId(IResponse, IRequest)

View Source
Declaration
public static string CreatePermanentSessionId(this IResponse res, IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IResponseres
ServiceStack.Web.IRequestreq

CreateTemporarySessionId(IResponse, IRequest)

View Source
Declaration
public static string CreateTemporarySessionId(this IResponse res, IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IResponseres
ServiceStack.Web.IRequestreq

CreateSessionId(IRequest, IResponse, String, String)

View Source
Declaration
public static string CreateSessionId(this IRequest req, IResponse res, string sessionKey, string sessionId)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.StringsessionKey
System.StringsessionId

CreateTemporarySessionId(IRequest, String)

View Source
Declaration
public static string CreateTemporarySessionId(this IRequest req, string sessionId)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.StringsessionId

CreatePermanentSessionId(IRequest, String)

View Source
Declaration
public static string CreatePermanentSessionId(this IRequest req, string sessionId)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.StringsessionId

IsPermanentSession(IRequest)

View Source
Declaration
public static bool IsPermanentSession(this IRequest req)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetSessionOptions(IRequest)

View Source
Declaration
public static HashSet<string> GetSessionOptions(this IRequest httpReq)
Returns

System.Collections.Generic.HashSet<System.String>

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

GetUserAuthName(IAuthSession)

View Source
Declaration
public static string GetUserAuthName(this IAuthSession session)
Returns

System.String

Parameters
TypeName
ServiceStack.Auth.IAuthSessionsession

GetUserAuthIdOrName(IAuthSession)

View Source
Declaration
public static string GetUserAuthIdOrName(this IAuthSession session)
Returns

System.String

Parameters
TypeName
ServiceStack.Auth.IAuthSessionsession

UpdateSession(IAuthSession, IUserAuth)

View Source
Declaration
public static void UpdateSession(this IAuthSession session, IUserAuth userAuth)
Parameters
TypeName
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Auth.IUserAuthuserAuth

AddSessionOptions(IRequest, String[])

View Source
Declaration
public static HashSet<string> AddSessionOptions(this IRequest req, params string[] options)
Returns

System.Collections.Generic.HashSet<System.String>

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.String[]options

GetSessionKey(IRequest)

View Source
Declaration
public static string GetSessionKey(IRequest httpReq = null)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

SessionAs<TUserSession>(ICacheClient, IRequest, IResponse)

View Source
Declaration
public static TUserSession SessionAs<TUserSession>(this ICacheClient cache, IRequest httpReq = null, IResponse httpRes = null)
Returns

<TUserSession>

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes
Type Parameters
  • TUserSession

SessionAsAsync<TUserSession>(ICacheClientAsync, IRequest, IResponse, CancellationToken)

View Source
Declaration
public static Task<TUserSession> SessionAsAsync<TUserSession>(this ICacheClientAsync cache, IRequest httpReq = null, IResponse httpRes = null, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<<TUserSession>>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes
System.Threading.CancellationTokentoken
Type Parameters
  • TUserSession

GetUntypedSession(ICacheClient, IRequest, IResponse)

View Source
Declaration
public static IAuthSession GetUntypedSession(this ICacheClient cache, IRequest httpReq = null, IResponse httpRes = null)
Returns

ServiceStack.Auth.IAuthSession

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes

GetUntypedSessionAsync(ICacheClientAsync, IRequest, IResponse, CancellationToken)

View Source
Declaration
public static async Task<IAuthSession> GetUntypedSessionAsync(this ICacheClientAsync cache, IRequest httpReq = null, IResponse httpRes = null, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<ServiceStack.Auth.IAuthSession>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes
System.Threading.CancellationTokentoken

ClearSession(ICacheClient, IRequest)

View Source
Declaration
public static void ClearSession(this ICacheClient cache, IRequest httpReq = null)
Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
ServiceStack.Web.IRequesthttpReq

ClearSessionAsync(ICacheClientAsync, IRequest, CancellationToken)

View Source
Declaration
public static Task ClearSessionAsync(this ICacheClientAsync cache, IRequest httpReq = null, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
ServiceStack.Web.IRequesthttpReq
System.Threading.CancellationTokentoken

GetSessionBag(IRequest)

View Source
Declaration
public static ISession GetSessionBag(this IRequest request)
Returns

ServiceStack.Caching.ISession

Parameters
TypeName
ServiceStack.Web.IRequestrequest

GetSessionBagAsync(IRequest, CancellationToken)

View Source
Declaration
public static ISessionAsync GetSessionBagAsync(this IRequest request, CancellationToken token = default(CancellationToken))
Returns

ServiceStack.Caching.ISessionAsync

Parameters
TypeName
ServiceStack.Web.IRequestrequest
System.Threading.CancellationTokentoken

GetSessionBag(IServiceBase)

View Source
Declaration
public static ISession GetSessionBag(this IServiceBase service)
Returns

ServiceStack.Caching.ISession

Parameters
TypeName
ServiceStack.IServiceBaseservice

GetSessionBagAsync(IServiceBase, CancellationToken)

View Source
Declaration
public static ISessionAsync GetSessionBagAsync(this IServiceBase service, CancellationToken token = default(CancellationToken))
Returns

ServiceStack.Caching.ISessionAsync

Parameters
TypeName
ServiceStack.IServiceBaseservice
System.Threading.CancellationTokentoken

Get<T>(ISession)

View Source
Declaration
public static T Get<T>(this ISession session)
Returns

<T>

Parameters
TypeName
ServiceStack.Caching.ISessionsession
Type Parameters
  • T

GetAsync<T>(ISessionAsync, CancellationToken)

View Source
Declaration
public static Task<T> GetAsync<T>(this ISessionAsync session, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<<T>>

Parameters
TypeName
ServiceStack.Caching.ISessionAsyncsession
System.Threading.CancellationTokentoken
Type Parameters
  • T

Set<T>(ISession, T)

View Source
Declaration
public static void Set<T>(this ISession session, T value)
Parameters
TypeName
ServiceStack.Caching.ISessionsession
<T>value
Type Parameters
  • T

SetAsync<T>(ISessionAsync, T, CancellationToken)

View Source
Declaration
public static Task SetAsync<T>(this ISessionAsync session, T value, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Caching.ISessionAsyncsession
<T>value
System.Threading.CancellationTokentoken
Type Parameters
  • T

Remove<T>(ISession)

View Source
Declaration
public static void Remove<T>(this ISession session)
Parameters
TypeName
ServiceStack.Caching.ISessionsession
Type Parameters
  • T

RemoveAsync<T>(ISessionAsync, CancellationToken)

View Source
Declaration
public static Task RemoveAsync<T>(this ISessionAsync session, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Caching.ISessionAsyncsession
System.Threading.CancellationTokentoken
Type Parameters
  • T

DeleteSessionCookies(IResponse)

View Source
Declaration
public static void DeleteSessionCookies(this IResponse response)
Parameters
TypeName
ServiceStack.Web.IResponseresponse

DeleteJwtCookie(IResponse)

View Source
Declaration
public static void DeleteJwtCookie(this IResponse response)
Parameters
TypeName
ServiceStack.Web.IResponseresponse

GenerateNewSessionCookiesAsync(IRequest, IAuthSession, CancellationToken)

View Source
Declaration
public static async Task GenerateNewSessionCookiesAsync(this IRequest req, IAuthSession session, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Auth.IAuthSessionsession
System.Threading.CancellationTokentoken

ToAuthUserSession(IAuthSession)

View Source
Declaration
public static AuthUserSession ToAuthUserSession(this IAuthSession session)
Returns

ServiceStack.AuthUserSession

Parameters
TypeName
ServiceStack.Auth.IAuthSessionsession

FromAuthUserSession(AuthUserSession)

View Source
Declaration
public static IAuthSession FromAuthUserSession(this AuthUserSession session)
Returns

ServiceStack.Auth.IAuthSession

Parameters
TypeName
ServiceStack.AuthUserSessionsession