Skip to main content

HostContext

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

Properties

RequestContext

View Source
Declaration
public static RequestContext RequestContext { get; }

AppHost

View Source
Declaration
public static ServiceStackHost AppHost { get; }

IsAspNetHost

View Source
Declaration
public static bool IsAspNetHost { get; }

IsHttpListenerHost

View Source
Declaration
public static bool IsHttpListenerHost { get; }

IsNetCore

View Source
Declaration
public static bool IsNetCore { get; }

Container

View Source
Declaration
public static Container Container { get; }

ServiceController

View Source
Declaration
public static ServiceController ServiceController { get; }

MetadataPagesConfig

View Source
Declaration
public static MetadataPagesConfig MetadataPagesConfig { get; }

ContentTypes

View Source
Declaration
public static IContentTypes ContentTypes { get; }

Config

View Source
Declaration
public static HostConfig Config { get; }

AppSettings

View Source
Declaration
public static IAppSettings AppSettings { get; }

Metadata

View Source
Declaration
public static ServiceMetadata Metadata { get; }

ServiceName

View Source
Declaration
public static string ServiceName { get; }

DebugMode

View Source
Declaration
public static bool DebugMode { get; }

StrictMode

View Source
Declaration
public static bool StrictMode { get; }

TestMode

View Source
Declaration
public static bool TestMode { get; set; }

VirtualFiles

Read/Write Virtual FileSystem. Defaults to FileSystemVirtualPathProvider

View Source
Declaration
public static IVirtualFiles VirtualFiles { get; }

VirtualFileSources

Cascading collection of virtual file sources, inc. Embedded Resources, File System, In Memory, S3

View Source
Declaration
public static IVirtualPathProvider VirtualFileSources { get; }

RootDirectory

The WebRoot VFS Directory of VirtualFilesSources

View Source
Declaration
public static IVirtualDirectory RootDirectory { get; }

ContentRootDirectory

The ContentRoot VFS Directory of VirtualFiles

View Source
Declaration
public static IVirtualDirectory ContentRootDirectory { get; }

FileSystemVirtualFiles

The FileSystem VirtualFiles provider in VirtualFileSources

View Source
Declaration
public static FileSystemVirtualFiles FileSystemVirtualFiles { get; }

MemoryVirtualFiles

The Memory VirtualFiles provider in VirtualFileSources

View Source
Declaration
public static MemoryVirtualFiles MemoryVirtualFiles { get; }

GistVirtualFiles

The GistVirtualFiles provider in VirtualFileSources (if any)

View Source
Declaration
public static GistVirtualFiles GistVirtualFiles { get; }

Cache

View Source
Declaration
public static ICacheClient Cache { get; }

CacheClientAsync

View Source
Declaration
public static ICacheClientAsync CacheClientAsync { get; }

LocalCache

View Source
Declaration
public static MemoryCacheClient LocalCache { get; }

DefaultOperationNamespace

View Source
Declaration
public static string DefaultOperationNamespace { get; set; }

Fields

Async

View Source
Declaration
public static AsyncContext Async

Methods

AssertAppHost()

View Source
Declaration
public static ServiceStackHost AssertAppHost()
Returns

ServiceStack.ServiceStackHost

TryResolve<T>()

View Source
Declaration
public static T TryResolve<T>()
Returns

<T>

Type Parameters
  • T

Resolve<T>()

View Source
Declaration
public static T Resolve<T>()
Returns

<T>

Type Parameters
  • T

ApplyCustomHandlerRequestFilters(IRequest, IResponse)

View Source
Declaration
public static bool ApplyCustomHandlerRequestFilters(IRequest httpReq, IResponse httpRes)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes

ApplyPreRequestFilters(IRequest, IResponse)

View Source
Declaration
public static bool ApplyPreRequestFilters(IRequest httpReq, IResponse httpRes)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes

ApplyRequestFiltersAsync(IRequest, IResponse, Object)

View Source
Declaration
public static Task ApplyRequestFiltersAsync(IRequest httpReq, IResponse httpRes, object requestDto)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes
System.ObjectrequestDto

ApplyResponseFiltersAsync(IRequest, IResponse, Object)

View Source
Declaration
public static Task ApplyResponseFiltersAsync(IRequest httpReq, IResponse httpRes, object response)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes
System.Objectresponse

CreateServiceRunner<TRequest>(ActionContext)

View Source
Declaration
public static IServiceRunner<TRequest> CreateServiceRunner<TRequest>(ActionContext actionContext)
Returns

ServiceStack.Web.IServiceRunner<TRequest>

Parameters
TypeName
ServiceStack.Host.ActionContextactionContext
Type Parameters
  • TRequest

AssertPlugin<T>()

View Source
Declaration
public static T AssertPlugin<T>()
where T : class, IPlugin
Returns

<T>

Type Parameters
  • T

GetPlugin<T>()

View Source
Declaration
public static T GetPlugin<T>()
where T : class, IPlugin
Returns

<T>

Type Parameters
  • T

HasPlugin<T>()

View Source
Declaration
public static bool HasPlugin<T>()
where T : class, IPlugin
Returns

System.Boolean

Type Parameters
  • T

Release(Object)

View Source
Declaration
public static void Release(object service)
Parameters
TypeName
System.Objectservice

UnauthorizedAccess(RequestAttributes)

View Source
Declaration
public static UnauthorizedAccessException UnauthorizedAccess(RequestAttributes requestAttrs)
Returns

System.UnauthorizedAccessException

Parameters
TypeName
ServiceStack.RequestAttributesrequestAttrs

ResolveLocalizedString(String, IRequest)

View Source
Declaration
public static string ResolveLocalizedString(string text, IRequest request = null)
Returns

System.String

Parameters
TypeName
System.Stringtext
ServiceStack.Web.IRequestrequest

ResolveAbsoluteUrl(String, IRequest)

View Source
Declaration
public static string ResolveAbsoluteUrl(string virtualPath, IRequest httpReq)
Returns

System.String

Parameters
TypeName
System.StringvirtualPath
ServiceStack.Web.IRequesthttpReq

ResolvePhysicalPath(String, IRequest)

View Source
Declaration
public static string ResolvePhysicalPath(string virtualPath, IRequest httpReq)
Returns

System.String

Parameters
TypeName
System.StringvirtualPath
ServiceStack.Web.IRequesthttpReq

GetDefaultNamespace()

View Source
Declaration
public static string GetDefaultNamespace()
Returns

System.String

RaiseServiceException(IRequest, Object, Exception)

View Source
Declaration
public static Task<object> RaiseServiceException(IRequest httpReq, object request, Exception ex)
Returns

System.Threading.Tasks.Task<System.Object>

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
System.Objectrequest
System.Exceptionex

RaiseUncaughtException(IRequest, IResponse, String, Exception)

View Source
Declaration
public static Task RaiseUncaughtException(IRequest httpReq, IResponse httpRes, string operationName, Exception ex)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes
System.StringoperationName
System.Exceptionex

RaiseGatewayException(IRequest, Object, Exception)

View Source
Declaration
public static Task RaiseGatewayException(IRequest httpReq, object request, Exception ex)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
System.Objectrequest
System.Exceptionex

RaiseAndHandleException(IRequest, IResponse, String, Exception)

View Source
Declaration
public static async Task RaiseAndHandleException(IRequest httpReq, IResponse httpRes, string operationName, Exception ex)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes
System.StringoperationName
System.Exceptionex

ResolveService<T>(HttpContextBase)

Resolves and auto-wires a ServiceStack Service from a ASP.NET HttpContext.

View Source
Declaration
public static T ResolveService<T>(HttpContextBase httpCtx = null)
where T : class, IRequiresRequest
Returns

<T>

Parameters
TypeName
System.Web.HttpContextBasehttpCtx
Type Parameters
  • T

ResolveService<T>(HttpListenerContext)

Resolves and auto-wires a ServiceStack Service from a HttpListenerContext.

View Source
Declaration
public static T ResolveService<T>(HttpListenerContext httpCtx)
where T : class, IRequiresRequest
Returns

<T>

Parameters
TypeName
System.Net.HttpListenerContexthttpCtx
Type Parameters
  • T

ResolveService<T>(IRequest)

Resolves and auto-wires a ServiceStack Service.

View Source
Declaration
public static T ResolveService<T>(IRequest httpReq)
where T : class, IRequiresRequest
Returns

<T>

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
Type Parameters
  • T

ResolveService<T>(IRequest, T)

View Source
Declaration
public static T ResolveService<T>(IRequest httpReq, T service)
Returns

<T>

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
<T>service
Type Parameters
  • T

HasValidAuthSecret(IRequest)

View Source
Declaration
public static bool HasValidAuthSecret(IRequest httpReq)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

HasFeature(Feature)

View Source
Declaration
public static bool HasFeature(Feature feature)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Featurefeature

GetCurrentRequest()

View Source
Declaration
public static IRequest GetCurrentRequest()
Returns

ServiceStack.Web.IRequest

TryGetCurrentRequest()

View Source
Declaration
public static IRequest TryGetCurrentRequest()
Returns

ServiceStack.Web.IRequest

GetAuthSecretSession()

View Source
Declaration
public static IAuthSession GetAuthSecretSession()
Returns

ServiceStack.Auth.IAuthSession

FindFreeTcpPort(Int32, Int32)

View Source
Declaration
public static int FindFreeTcpPort(int startingFrom = 5000, int endingAt = 65535)
Returns

System.Int32

Parameters
TypeName
System.Int32startingFrom
System.Int32endingAt

ConfigureAppHost(Action<ServiceStackHost>, Action<ServiceStackHost>, Action<ServiceStackHost>, Action<ServiceStackHost>)

View Source
Declaration
public static void ConfigureAppHost(Action<ServiceStackHost> beforeConfigure = null, Action<ServiceStackHost> afterConfigure = null, Action<ServiceStackHost> afterPluginsLoaded = null, Action<ServiceStackHost> afterAppHostInit = null)
Parameters
TypeName
System.Action<ServiceStack.ServiceStackHost>beforeConfigure
System.Action<ServiceStack.ServiceStackHost>afterConfigure
System.Action<ServiceStack.ServiceStackHost>afterPluginsLoaded
System.Action<ServiceStack.ServiceStackHost>afterAppHostInit

Reset()

View Source
Declaration
public static void Reset()