Skip to main content

RequestContext

Abstraction to provide a context per request. in aspnet.web its equivalent to System.Web.HttpContext.Current.Items falls back to CallContext

Assembly: ServiceStack.dll​
View Source​
Declaration
public class RequestContext

Properties​

Items​

Gets a list of items for this request.

View Source​
Declaration
public virtual IDictionary Items { get; set; }

Fields​

Instance​

View Source​
Declaration
public static readonly RequestContext Instance

UseThreadStatic​

Tell ServiceStack to use ThreadStatic Items Collection for RequestScoped items. Warning: ThreadStatic Items aren't pinned to the same request in async services which callback on different threads.

View Source​
Declaration
public static bool UseThreadStatic

RequestItems​

View Source​
Declaration
[ThreadStatic]
public static IDictionary RequestItems

Methods​

StartRequestContext()​

Start a new Request context, everything deeper in Async pipeline will get this new RequestContext dictionary.

View Source​
Declaration
public void StartRequestContext()

GetOrCreate<T>(Func<T>)​

View Source​
Declaration
public T GetOrCreate<T>(Func<T> createFn)
Returns​

<T>

Parameters​
TypeName
System.Func<<T>>createFn
Type Parameters​
  • T

EndRequest()​

View Source​
Declaration
public void EndRequest()

TrackDisposable(IDisposable)​

Track any IDisposable's to dispose of at the end of the request in IAppHost.OnEndRequest()

View Source​
Declaration
public void TrackDisposable(IDisposable instance)
Parameters​
TypeName
System.IDisposableinstance

ReleaseDisposables()​

Release currently registered dependencies for this request

View Source​
Declaration
public bool ReleaseDisposables()
Returns​

System.Boolean: true if any dependencies were released