Skip to main content

ServiceStackHost

Assembly: ServiceStack.dll
View Source
Declaration
public abstract class ServiceStackHost : IAppHost, IResolver, IFunqlet, IHasContainer, IDisposable

Properties

IsDebugLogEnabled

View Source
Declaration
public bool IsDebugLogEnabled { get; }

Instance

Singleton access to AppHost

View Source
Declaration
public static ServiceStackHost Instance { get; protected set; }

StartedAt

When the AppHost was instantiated.

View Source
Declaration
public DateTime StartedAt { get; set; }

AfterInitAt

When the Init function was done. Called at begin of ServiceStack.ServiceStackHost.OnAfterInit()

View Source
Declaration
public DateTime? AfterInitAt { get; set; }

ReadyAt

When all configuration was completed. Called at the end of ServiceStack.ServiceStackHost.OnAfterInit()

View Source
Declaration
public DateTime? ReadyAt { get; set; }

TestMode

If app currently runs for unit tests. Used for overwriting AuthSession.

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

PathBase

The base path ServiceStack is hosted on

View Source
Declaration
public virtual string PathBase { get; set; }

ServiceAssemblies

The assemblies reflected to find api services. These can be provided in the constructor call.

View Source
Declaration
public List<Assembly> ServiceAssemblies { get; }

HasInit

Whether AppHost has been already initialized

View Source
Declaration
public static bool HasInit { get; }

HasStarted

Whether AppHost configuration is done. Note: It doesn't mean the start function was called.

View Source
Declaration
public bool HasStarted { get; }

AppName

Sharp App Name

View Source
Declaration
public string AppName { get; set; }

ServiceName

The public name of this App

View Source
Declaration
public string ServiceName { get; set; }

AppSettings

ServiceStack's Configuration API, see: https://docs.servicestack.net/appsettings

View Source
Declaration
public IAppSettings AppSettings { get; set; }

Metadata

The populated Metadata for this AppHost's Services

View Source
Declaration
public ServiceMetadata Metadata { get; set; }

ServiceController

The ServiceController that executes Services

View Source
Declaration
public ServiceController ServiceController { get; set; }

RpcGateway

Provides a pure object model for executing the full HTTP Request pipeline which returns the Response DTO back to ASP .NET Core gRPC which handles sending the response back to the HTTP/2 connected client.

View Source
Declaration
public RpcGateway RpcGateway { get; set; }

ExcludeAutoRegisteringServiceTypes

View Source
Declaration
public HashSet<Type> ExcludeAutoRegisteringServiceTypes { get; set; }

Container

The AppHost.Container. Note: it is not thread safe to register dependencies after AppStart.

View Source
Declaration
public virtual Container Container { get; }

Routes

Dynamically register Service Routes

View Source
Declaration
public IServiceRoutes Routes { get; set; }

RestPaths

Registered Routes

View Source
Declaration
public List<RestPath> RestPaths { get; set; }

RequestBinders

Register custom Request Binder

View Source
Declaration
public Dictionary<Type, Func<IRequest, object>> RequestBinders { get; }

ContentTypes

Manage registered Content Types & their sync/async serializers supported by this AppHost

View Source
Declaration
public IContentTypes ContentTypes { get; set; }

PreRequestFilters

Collection of PreRequest filters. They are called before each request is handled by a service, but after an HttpHandler is by the ServiceStack.HttpHandlerFactory chosen. called in ServiceStack.ServiceStackHost.ApplyPreRequestFilters(ServiceStack.Web.IRequest%2cServiceStack.Web.IResponse).

View Source
Declaration
public List<Action<IRequest, IResponse>> PreRequestFilters { get; set; }

RequestConverters

Collection of RequestConverters. Can be used to convert/change Input Dto Called after routing and model binding, but before request filters. All request converters are called unless ServiceStack.Web.IResponse.IsClosed Converter can return null, original model will be used.

Note one converter could influence the input for the next converter!

View Source
Declaration
public List<Func<IRequest, object, Task<object>>> RequestConverters { get; set; }

ResponseConverters

Collection of ResponseConverters. Can be used to convert/change Output Dto

Called directly after response is handled, even before ServiceStack.ServiceStackHost.ApplyResponseFiltersAsync(ServiceStack.Web.IRequest%2cServiceStack.Web.IResponse%2cSystem.Object)!

View Source
Declaration
public List<Func<IRequest, object, Task<object>>> ResponseConverters { get; set; }

GlobalRequestFilters

View Source
Declaration
public List<Action<IRequest, IResponse, object>> GlobalRequestFilters { get; set; }

GlobalRequestFiltersAsync

View Source
Declaration
public List<Func<IRequest, IResponse, object, Task>> GlobalRequestFiltersAsync { get; set; }

GlobalTypedRequestFilters

View Source
Declaration
public Dictionary<Type, ITypedFilter> GlobalTypedRequestFilters { get; set; }

GlobalTypedRequestFiltersAsync

View Source
Declaration
public Dictionary<Type, ITypedFilterAsync> GlobalTypedRequestFiltersAsync { get; set; }

GlobalResponseFilters

View Source
Declaration
public List<Action<IRequest, IResponse, object>> GlobalResponseFilters { get; set; }

GlobalResponseFiltersAsync

View Source
Declaration
public List<Func<IRequest, IResponse, object, Task>> GlobalResponseFiltersAsync { get; set; }

GlobalTypedResponseFilters

View Source
Declaration
public Dictionary<Type, ITypedFilter> GlobalTypedResponseFilters { get; set; }

GlobalTypedResponseFiltersAsync

View Source
Declaration
public Dictionary<Type, ITypedFilterAsync> GlobalTypedResponseFiltersAsync { get; set; }

GlobalMessageRequestFilters

View Source
Declaration
public List<Action<IRequest, IResponse, object>> GlobalMessageRequestFilters { get; }

GlobalMessageRequestFiltersAsync

View Source
Declaration
public List<Func<IRequest, IResponse, object, Task>> GlobalMessageRequestFiltersAsync { get; }

GlobalTypedMessageRequestFilters

View Source
Declaration
public Dictionary<Type, ITypedFilter> GlobalTypedMessageRequestFilters { get; set; }

GlobalMessageResponseFilters

View Source
Declaration
public List<Action<IRequest, IResponse, object>> GlobalMessageResponseFilters { get; }

GlobalMessageResponseFiltersAsync

View Source
Declaration
public List<Func<IRequest, IResponse, object, Task>> GlobalMessageResponseFiltersAsync { get; }

GlobalTypedMessageResponseFilters

View Source
Declaration
public Dictionary<Type, ITypedFilter> GlobalTypedMessageResponseFilters { get; set; }

ViewEngines

Lists of view engines for this app. If view is needed list is looped until view is found.

View Source
Declaration
public List<IViewEngine> ViewEngines { get; set; }

ServiceExceptionHandlers

View Source
Declaration
public List<HandleServiceExceptionDelegate> ServiceExceptionHandlers { get; set; }

ServiceExceptionHandlersAsync

View Source
Declaration
public List<HandleServiceExceptionAsyncDelegate> ServiceExceptionHandlersAsync { get; set; }

UncaughtExceptionHandlers

View Source
Declaration
public List<HandleUncaughtExceptionDelegate> UncaughtExceptionHandlers { get; set; }

UncaughtExceptionHandlersAsync

View Source
Declaration
public List<HandleUncaughtExceptionAsyncDelegate> UncaughtExceptionHandlersAsync { get; set; }

GatewayExceptionHandlers

View Source
Declaration
public List<HandleGatewayExceptionDelegate> GatewayExceptionHandlers { get; set; }

GatewayExceptionHandlersAsync

View Source
Declaration
public List<HandleGatewayExceptionAsyncDelegate> GatewayExceptionHandlersAsync { get; set; }

GlobalBeforeConfigure

Register static callbacks fired just before AppHost.Configure()

View Source
Declaration
public static List<Action<ServiceStackHost>> GlobalBeforeConfigure { get; }

BeforeConfigure

Register callbacks fired just before AppHost.Configure()

View Source
Declaration
public List<Action<ServiceStackHost>> BeforeConfigure { get; set; }

GlobalAfterConfigure

Register static callbacks fired just after AppHost.Configure()

View Source
Declaration
public static List<Action<ServiceStackHost>> GlobalAfterConfigure { get; }

AfterConfigure

Register callbacks fired just after AppHost.Configure()

View Source
Declaration
public List<Action<ServiceStackHost>> AfterConfigure { get; set; }

GlobalAfterPluginsLoaded

Register static callbacks fired just after plugins are loaded

View Source
Declaration
public static List<Action<ServiceStackHost>> GlobalAfterPluginsLoaded { get; }

AfterPluginsLoaded

Register callbacks fired just after plugins are loaded

View Source
Declaration
public List<Action<ServiceStackHost>> AfterPluginsLoaded { get; set; }

AfterInitCallbacks

Register callbacks that's fired after the AppHost is initialized

View Source
Declaration
public List<Action<IAppHost>> AfterInitCallbacks { get; set; }

GlobalAfterAppHostInit

Register static callbacks fired after the AppHost is initialized

View Source
Declaration
public static List<Action<ServiceStackHost>> GlobalAfterAppHostInit { get; }

OnDisposeCallbacks

Register callbacks that's fired when AppHost is disposed

View Source
Declaration
public List<Action<IAppHost>> OnDisposeCallbacks { get; set; }

OnEndRequestCallbacks

Register callbacks to execute at the end of a Request

View Source
Declaration
public List<Action<IRequest>> OnEndRequestCallbacks { get; set; }

RawHttpHandlers

Register highest priority IHttpHandler callbacks

View Source
Declaration
public List<Func<IHttpRequest, IHttpHandler>> RawHttpHandlers { get; set; }

CatchAllHandlers

Get "Catch All" IHttpHandler predicate IHttpHandler's, e.g. Used by HTML View Engines

View Source
Declaration
public List<HttpHandlerResolverDelegate> CatchAllHandlers { get; set; }

FallbackHandlers

Register fallback Request Handlers e.g. Used by #Script & Razor Page Based Routing

View Source
Declaration
public List<HttpHandlerResolverDelegate> FallbackHandlers { get; set; }

GlobalHtmlErrorHttpHandler

Fallback IServiceStackHandler to handle Error Responses

View Source
Declaration
public IServiceStackHandler GlobalHtmlErrorHttpHandler { get; set; }

CustomErrorHttpHandlers

Register Custom IServiceStackHandler to handle specific HttpStatusCode's

View Source
Declaration
public Dictionary<HttpStatusCode, IServiceStackHandler> CustomErrorHttpHandlers { get; set; }

StartUpErrors

Captured StartUp Exceptions

View Source
Declaration
public List<ResponseStatus> StartUpErrors { get; set; }

AsyncErrors

Captured Unobserved Async Errors

View Source
Declaration
public List<ResponseStatus> AsyncErrors { get; set; }

PluginsLoaded

Which plugins were loaded in this AppHost

View Source
Declaration
public List<string> PluginsLoaded { get; set; }

Plugins

Collection of added plugins.

View Source
Declaration
public List<IPlugin> Plugins { get; set; }

VirtualFiles

Writable Virtual File Source, uses FileSystemVirtualFiles at content root by default

View Source
Declaration
public IVirtualFiles VirtualFiles { get; set; }

VirtualFileSources

Virtual File Sources from WebRoot, typically a MultiVirtualFiles containing a cascading list of Sources

View Source
Declaration
public IVirtualPathProvider VirtualFileSources { get; set; }

RootDirectory

FileSystem VFS for WebRoot

View Source
Declaration
public IVirtualDirectory RootDirectory { get; }

ContentRootDirectory

The Content Root Directory for this AppHost

View Source
Declaration
public IVirtualDirectory ContentRootDirectory { get; }

InsertVirtualFileSources

Insert higher priority VFS providers at the start of the VFS providers list

View Source
Declaration
public List<IVirtualPathProvider> InsertVirtualFileSources { get; set; }

AddVirtualFileSources

Append lower priority VFS providers at the end of the VFS providers list

View Source
Declaration
public List<IVirtualPathProvider> AddVirtualFileSources { get; set; }

GatewayRequestFilters

View Source
Declaration
public List<Action<IRequest, object>> GatewayRequestFilters { get; set; }

GatewayRequestFiltersAsync

View Source
Declaration
public List<Func<IRequest, object, Task>> GatewayRequestFiltersAsync { get; set; }

GatewayResponseFilters

View Source
Declaration
public List<Action<IRequest, object>> GatewayResponseFilters { get; set; }

GatewayResponseFiltersAsync

View Source
Declaration
public List<Func<IRequest, object, Task>> GatewayResponseFiltersAsync { get; set; }

DefaultScriptContext

The fallback ScriptContext to use if no SharpPagesFeature plugin was registered

View Source
Declaration
public ScriptContext DefaultScriptContext { get; set; }

ScriptContext

Global #Script ScriptContext for AppHost. Returns SharpPagesFeature plugin or fallsback to DefaultScriptContext.

View Source
Declaration
public ScriptContext ScriptContext { get; }

Config

The Configuration for this AppHost

View Source
Declaration
public HostConfig Config { get; set; }

OnPreRegisterPlugins

View Source
Declaration
public Dictionary<Type, List<Action<IPlugin>>> OnPreRegisterPlugins { get; set; }

OnPostRegisterPlugins

View Source
Declaration
public Dictionary<Type, List<Action<IPlugin>>> OnPostRegisterPlugins { get; set; }

OnAfterPluginsLoaded

View Source
Declaration
public Dictionary<Type, List<Action<IPlugin>>> OnAfterPluginsLoaded { get; set; }

MetadataPagesConfig

Configuration of ServiceStack's /metadata pages

View Source
Declaration
public MetadataPagesConfig MetadataPagesConfig { get; }

Fields

Log

View Source
Declaration
protected ILog Log

Methods

ExportSoapOperationTypes(List<Type>)

View Source
Declaration
public virtual List<Type> ExportSoapOperationTypes(List<Type> operationTypes)
Returns

System.Collections.Generic.List<System.Type>

Parameters
TypeName
System.Collections.Generic.List<System.Type>operationTypes

ExportSoapType(Type)

View Source
Declaration
public virtual bool ExportSoapType(Type type)
Returns

System.Boolean

Parameters
TypeName
System.Typetype

WriteSoapMessage(IRequest, Message, Stream)

View Source
Declaration
public virtual void WriteSoapMessage(IRequest req, Message message, Stream outputStream)
Parameters
TypeName
ServiceStack.Web.IRequestreq
System.ServiceModel.Channels.Messagemessage
System.IO.StreamoutputStream

IsReady()

Whether AppHost is ready configured and either ready to run or already running. Equals ServiceStack.ServiceStackHost.HasStarted

View Source
Declaration
public static bool IsReady()
Returns

System.Boolean

Configure(Container)

Configure your AppHost and its dependencies

View Source
Declaration
public abstract void Configure(Container container)
Parameters
TypeName
Funq.Containercontainer

CreateServiceController(Assembly[])

View Source
Declaration
protected virtual ServiceController CreateServiceController(params Assembly[] assembliesWithServices)
Returns

ServiceStack.Host.ServiceController

Parameters
TypeName
System.Reflection.Assembly[]assembliesWithServices

CreateServiceController(Type[])

View Source
Declaration
protected virtual ServiceController CreateServiceController(params Type[] serviceTypes)
Returns

ServiceStack.Host.ServiceController

Parameters
TypeName
System.Type[]serviceTypes

SetConfig(HostConfig)

Set the host config of the AppHost.

View Source
Declaration
public virtual void SetConfig(HostConfig config)
Parameters
TypeName
ServiceStack.HostConfigconfig

Init()

Initializes the AppHost. Calls the ServiceStack.ServiceStackHost.Configure(Funq.Container) method. Should be called before start.

View Source
Declaration
public virtual ServiceStackHost Init()
Returns

ServiceStack.ServiceStackHost

OnReady()

View Source
Declaration
protected virtual void OnReady()

ConfigureLogging()

View Source
Declaration
public virtual void ConfigureLogging()

RegisterLicenseKey(String)

View Source
Declaration
protected virtual void RegisterLicenseKey(string licenseKeyText)
Parameters
TypeName
System.StringlicenseKeyText

PopulateArrayFilters()

View Source
Declaration
protected void PopulateArrayFilters()

GetWebRootPath()

Gets Full Directory Path of where the app is running

View Source
Declaration
public virtual string GetWebRootPath()
Returns

System.String

GetVirtualFileSources()

Override to intercept VFS Providers registered for this AppHost

View Source
Declaration
public virtual List<IVirtualPathProvider> GetVirtualFileSources()
Returns

System.Collections.Generic.List<ServiceStack.IO.IVirtualPathProvider>

GetVirtualFileSource<T>()

View Source
Declaration
public virtual T GetVirtualFileSource<T>()
where T : class
Returns

<T>

Type Parameters
  • T

Start(String)

Starts the AppHost. this methods needs to be overwritten in subclass to provider a listener to start handling requests.

View Source
Declaration
public virtual ServiceStackHost Start(string urlBase)
Returns

ServiceStack.ServiceStackHost

Parameters
TypeNameDescription
System.StringurlBaseUrl to listen to

|

EvalExpressionCached(String)

Evaluate Expressions in ServiceStack's ScriptContext. Can be overridden if you want to customize how different expressions are evaluated.

View Source
Declaration
public virtual object EvalExpressionCached(string expr)
Returns

System.Object

Parameters
TypeName
System.Stringexpr

EvalExpression(String)

View Source
Declaration
public virtual object EvalExpression(string expr)
Returns

System.Object

Parameters
TypeName
System.Stringexpr

EvalScriptValue(IScriptValue, IRequest, Dictionary<String, Object>)

Evaluate a script value, IScriptValue.Expression results are cached globally. If IRequest is provided, results from the same IScriptValue.Eval are cached per request.

View Source
Declaration
public virtual object EvalScriptValue(IScriptValue scriptValue, IRequest req = null, Dictionary<string, object> args = null)
Returns

System.Object

Parameters
TypeName
ServiceStack.IScriptValuescriptValue
ServiceStack.Web.IRequestreq
System.Collections.Generic.Dictionary<System.String,System.Object>args

EvalScriptValueAsync(IScriptValue, IRequest, Dictionary<String, Object>)

Evaluate a script value, IScriptValue.Expression results are cached globally. If IRequest is provided, results from the same IScriptValue.Eval are cached per request.

View Source
Declaration
public virtual async Task<object> EvalScriptValueAsync(IScriptValue scriptValue, IRequest req = null, Dictionary<string, object> args = null)
Returns

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

Parameters
TypeName
ServiceStack.IScriptValuescriptValue
ServiceStack.Web.IRequestreq
System.Collections.Generic.Dictionary<System.String,System.Object>args

EvalScript(PageResult, IRequest, Dictionary<String, Object>)

Override to intercept sync #Script execution

View Source
Declaration
public virtual object EvalScript(PageResult pageResult, IRequest req = null, Dictionary<string, object> args = null)
Returns

System.Object

Parameters
TypeName
ServiceStack.Script.PageResultpageResult
ServiceStack.Web.IRequestreq
System.Collections.Generic.Dictionary<System.String,System.Object>args

EvalScriptAsync(PageResult, IRequest, Dictionary<String, Object>)

Override to intercept async #Script execution

View Source
Declaration
public virtual async Task<object> EvalScriptAsync(PageResult pageResult, IRequest req = null, Dictionary<string, object> args = null)
Returns

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

Parameters
TypeName
ServiceStack.Script.PageResultpageResult
ServiceStack.Web.IRequestreq
System.Collections.Generic.Dictionary<System.String,System.Object>args

OnPreExecuteServiceFilter(IService, Object, IRequest, IResponse)

Executed immediately before a Service is executed. Use return to change the request DTO used, must be of the same type.

View Source
Declaration
public virtual object OnPreExecuteServiceFilter(IService service, object request, IRequest httpReq, IResponse httpRes)
Returns

System.Object

Parameters
TypeName
ServiceStack.IServiceservice
System.Objectrequest
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes

OnPostExecuteServiceFilter(IService, Object, IRequest, IResponse)

Executed immediately after a service is executed. Use return to change response used.

View Source
Declaration
public virtual object OnPostExecuteServiceFilter(IService service, object response, IRequest httpReq, IResponse httpRes)
Returns

System.Object

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

OnGatewayException(IRequest, Object, Exception)

Occurs when the Service throws an Service Gateway Exception

View Source
Declaration
public virtual async Task OnGatewayException(IRequest httpReq, object request, Exception ex)
Returns

System.Threading.Tasks.Task

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

OnServiceException(IRequest, Object, Exception)

Occurs when the Service throws an Exception.

View Source
Declaration
public virtual async Task<object> OnServiceException(IRequest httpReq, object request, Exception ex)
Returns

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

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

OnUncaughtException(IRequest, IResponse, String, Exception)

Occurs when an exception is thrown whilst processing a request.

View Source
Declaration
public virtual async Task OnUncaughtException(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

HandleUncaughtException(IRequest, IResponse, String, Exception)

View Source
Declaration
[Obsolete("Use HandleResponseException")]
protected virtual Task HandleUncaughtException(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

HandleResponseException(IRequest, IResponse, String, Exception)

Override to intercept Response Exceptions

View Source
Declaration
public virtual Task HandleResponseException(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

HandleShortCircuitedErrors(IRequest, IResponse, Object, HttpStatusCode, String)

View Source
Declaration
public virtual Task HandleShortCircuitedErrors(IRequest req, IResponse res, object requestDto, HttpStatusCode statusCode, string statusDescription = null)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto
System.Net.HttpStatusCodestatusCode
System.StringstatusDescription

HandleShortCircuitedErrors(IRequest, IResponse, Object)

Override to intercept Short Circuited Authentication Errors

View Source
Declaration
public virtual async Task HandleShortCircuitedErrors(IRequest req, IResponse res, object requestDto)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto

OnStartupException(Exception)

Override to intercept Exceptions thrown at Startup. Use StrictMode to rethrow Startup Exceptions

View Source
Declaration
public virtual void OnStartupException(Exception ex)
Parameters
TypeName
System.Exceptionex

OnStartupException(Exception, String, String)

View Source
Declaration
public virtual void OnStartupException(Exception ex, string target, string method)
Parameters
TypeName
System.Exceptionex
System.Stringtarget
System.Stringmethod

OnConfigLoad()

Override to intercept after the Config was loaded

View Source
Declaration
public virtual void OnConfigLoad()

OnAfterConfigChanged()

Override to intercept when the Config has changed

View Source
Declaration
public virtual void OnAfterConfigChanged()

OnBeforeInit()

Override to intercept before the AppHost is initialized

View Source
Declaration
public virtual void OnBeforeInit()

OnAfterInit()

Override to intercept after the AppHost has been initialized

View Source
Declaration
public virtual void OnAfterInit()

Release(Object)

Override to intercept releasing this Service or Attribute instance

View Source
Declaration
public virtual void Release(object instance)
Parameters
TypeName
System.Objectinstance

OnEndRequest(IRequest)

Override to intercept the final callback after executing this Request

View Source
Declaration
public virtual void OnEndRequest(IRequest request = null)
Parameters
TypeName
ServiceStack.Web.IRequestrequest

Register<T>(T)

Register singleton in the Ioc Container of the AppHost.

View Source
Declaration
public virtual void Register<T>(T instance)
Parameters
TypeName
<T>instance
Type Parameters
  • T

RegisterAs<T, TAs>()

Registers type to be automatically wired by the Ioc container of the AppHost.

View Source
Declaration
public virtual void RegisterAs<T, TAs>()
where T : TAs
Type Parameters
NameDescription
TConcrete type
TAsAbstract type

TryResolve<T>()

Tries to resolve type through the ioc container of the AppHost. Can return null.

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

<T>

Type Parameters
  • T

Resolve<T>()

Resolves Type through the Ioc container of the AppHost.

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

<T>

Type Parameters
  • T

GetPlugin<T>()

Looks for first plugin of this type in Plugins.

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

<T>

Type Parameters
  • T

HasPlugin<T>()

Returns true if App has this plugin registered

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

System.Boolean

Type Parameters
  • T

GetPlugin(Type)

Looks for first plugin of this type in Plugins.

View Source
Declaration
public IPlugin GetPlugin(Type pluginType)
Returns

ServiceStack.IPlugin

Parameters
TypeName
System.TypepluginType

HasPlugin(Type)

Returns true if App has this plugin registered

View Source
Declaration
public bool HasPlugin(Type pluginType)
Returns

System.Boolean

Parameters
TypeName
System.TypepluginType

CreateServiceRunner<TRequest>(ActionContext)

Override to use a Custom ServiceRunner to execute this Request DTO

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

ServiceStack.Web.IServiceRunner<TRequest>

Parameters
TypeName
ServiceStack.Host.ActionContextactionContext
Type Parameters
  • TRequest

ResolveLocalizedString(String, IRequest)

Override to use a localized string for internal routes & text used by ServiceStack

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

System.String

Parameters
TypeName
System.Stringtext
ServiceStack.Web.IRequestrequest

ResolveLocalizedStringFormat(String, Object[], IRequest)

Override to use a localized string for internal routes & text used by ServiceStack

View Source
Declaration
public virtual string ResolveLocalizedStringFormat(string text, object[] args, IRequest request = null)
Returns

System.String

Parameters
TypeName
System.Stringtext
System.Object[]args
ServiceStack.Web.IRequestrequest

ResolveAbsoluteUrl(String, IRequest)

Override to customize the Absolute URL for this virtualPath for this IRequest

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

System.String

Parameters
TypeName
System.StringvirtualPath
ServiceStack.Web.IRequesthttpReq

UseHttps(IRequest)

Override to change whether absolute links should use https:// URLs

View Source
Declaration
public virtual bool UseHttps(IRequest httpReq)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

GetBaseUrl(IRequest)

Override to customize the BaseUrl to use for this IRequest

View Source
Declaration
public virtual string GetBaseUrl(IRequest httpReq)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

ResolvePhysicalPath(String, IRequest)

Override to customize the Physical Path for this virtualPath for this IRequest

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

System.String

Parameters
TypeName
System.StringvirtualPath
ServiceStack.Web.IRequesthttpReq

ConfigurePlugin<T>(Action<T>)

Register a callback to configure a plugin just before it's registered

View Source
Declaration
public void ConfigurePlugin<T>(Action<T> configure)
where T : class, IPlugin
Parameters
TypeName
System.Action<<T>>configure
Type Parameters
  • T

PostConfigurePlugin<T>(Action<T>)

Register a callback to configure a plugin just after it's registered

View Source
Declaration
public void PostConfigurePlugin<T>(Action<T> configure)
where T : class, IPlugin
Parameters
TypeName
System.Action<<T>>configure
Type Parameters
  • T

AfterPluginLoaded<T>(Action<T>)

Register a callback to configure a plugin after AfterPluginsLoaded is run

View Source
Declaration
public void AfterPluginLoaded<T>(Action<T> configure)
where T : class, IPlugin
Parameters
TypeName
System.Action<<T>>configure
Type Parameters
  • T

LoadPlugin(IPlugin[])

Manually register Plugin to load

View Source
Declaration
public virtual void LoadPlugin(params IPlugin[] plugins)
Parameters
TypeName
ServiceStack.IPlugin[]plugins

ExecuteService(Object)

Override to intercept Service Requests

View Source
Declaration
public virtual object ExecuteService(object requestDto)
Returns

System.Object

Parameters
TypeName
System.ObjectrequestDto

ExecuteService(Object, IRequest)

Override to intercept Service Requests

View Source
Declaration
public virtual object ExecuteService(object requestDto, IRequest req)
Returns

System.Object

Parameters
TypeName
System.ObjectrequestDto
ServiceStack.Web.IRequestreq

ExecuteServiceAsync(Object, IRequest)

Override to intercept Async Service Requests

View Source
Declaration
public virtual Task<object> ExecuteServiceAsync(object requestDto, IRequest req)
Returns

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

Parameters
TypeName
System.ObjectrequestDto
ServiceStack.Web.IRequestreq

ExecuteService(Object, RequestAttributes)

Override to intercept Service Requests

View Source
Declaration
public virtual object ExecuteService(object requestDto, RequestAttributes requestAttributes)
Returns

System.Object

Parameters
TypeName
System.ObjectrequestDto
ServiceStack.RequestAttributesrequestAttributes

ExecuteMessage(IMessage)

Override to intercept MQ Requests

View Source
Declaration
public virtual object ExecuteMessage(IMessage mqMessage)
Returns

System.Object

Parameters
TypeName
ServiceStack.Messaging.IMessagemqMessage

ExecuteMessage(IMessage, IRequest)

Override to intercept MQ Requests

View Source
Declaration
public virtual object ExecuteMessage(IMessage dto, IRequest req)
Returns

System.Object

Parameters
TypeName
ServiceStack.Messaging.IMessagedto
ServiceStack.Web.IRequestreq

ExecuteMessageAsync(IMessage, CancellationToken)

Override to intercept MQ Requests

View Source
Declaration
public Task<object> ExecuteMessageAsync(IMessage mqMessage, CancellationToken token = default(CancellationToken))
Returns

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

Parameters
TypeName
ServiceStack.Messaging.IMessagemqMessage
System.Threading.CancellationTokentoken

ExecuteMessageAsync(IMessage, IRequest, CancellationToken)

Override to intercept MQ Requests

View Source
Declaration
public Task<object> ExecuteMessageAsync(IMessage mqMessage, IRequest req, CancellationToken token = default(CancellationToken))
Returns

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

Parameters
TypeName
ServiceStack.Messaging.IMessagemqMessage
ServiceStack.Web.IRequestreq
System.Threading.CancellationTokentoken

RegisterService<T>(String[])

Manually register ServiceStack Service at these routes

View Source
Declaration
public virtual void RegisterService<T>(params string[] atRestPaths)
where T : IService
Parameters
TypeName
System.String[]atRestPaths
Type Parameters
  • T

RegisterService(Type, String[])

Manually register ServiceStack Service at these routes

View Source
Declaration
public virtual void RegisterService(Type serviceType, params string[] atRestPaths)
Parameters
TypeName
System.TypeserviceType
System.String[]atRestPaths

RegisterServicesInAssembly(Assembly)

Register all ServiceStack Services found in this Assembly

View Source
Declaration
public void RegisterServicesInAssembly(Assembly assembly)
Parameters
TypeName
System.Reflection.Assemblyassembly

GetRouteAttributes(Type)

Return the [Route] attributes for this Request DTO Type

View Source
Declaration
public virtual RouteAttribute[] GetRouteAttributes(Type requestType)
Returns

ServiceStack.RouteAttribute[]

Parameters
TypeName
System.TyperequestType

GenerateWsdl(WsdlTemplateBase)

Override to customize WSDL returned in SOAP /metadata pages

View Source
Declaration
public virtual string GenerateWsdl(WsdlTemplateBase wsdlTemplate)
Returns

System.String

Parameters
TypeName
ServiceStack.Metadata.WsdlTemplateBasewsdlTemplate

RegisterTypedRequestFilter<T>(Action<IRequest, IResponse, T>)

Register Typed Service Request Filter

View Source
Declaration
public void RegisterTypedRequestFilter<T>(Action<IRequest, IResponse, T> filterFn)
Parameters
TypeName
System.Action<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>>filterFn
Type Parameters
  • T

RegisterTypedRequestFilterAsync<T>(Func<IRequest, IResponse, T, Task>)

Register Async Typed Service Request Filter

View Source
Declaration
public void RegisterTypedRequestFilterAsync<T>(Func<IRequest, IResponse, T, Task> filterFn)
Parameters
TypeName
System.Func<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>,System.Threading.Tasks.Task>filterFn
Type Parameters
  • T

RegisterTypedRequestFilter<T>(Func<Container, ITypedFilter<T>>)

Register Typed Service Request Filter

View Source
Declaration
public void RegisterTypedRequestFilter<T>(Func<Container, ITypedFilter<T>> filter)
Parameters
TypeName
System.Func<Funq.Container,ServiceStack.Host.ITypedFilter<<T>>>filter
Type Parameters
  • T

RegisterTypedRequestFilterAsync<T>(Func<Container, ITypedFilterAsync<T>>)

Register Async Typed Service Request Filter

View Source
Declaration
public void RegisterTypedRequestFilterAsync<T>(Func<Container, ITypedFilterAsync<T>> filter)
Parameters
TypeName
System.Func<Funq.Container,ServiceStack.Host.ITypedFilterAsync<<T>>>filter
Type Parameters
  • T

RegisterTypedResponseFilter<T>(Action<IRequest, IResponse, T>)

Register Typed Service Response Filter

View Source
Declaration
public void RegisterTypedResponseFilter<T>(Action<IRequest, IResponse, T> filterFn)
Parameters
TypeName
System.Action<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>>filterFn
Type Parameters
  • T

RegisterTypedResponseFilterAsync<T>(Func<IRequest, IResponse, T, Task>)

Register Async Typed Service Response Filter

View Source
Declaration
public void RegisterTypedResponseFilterAsync<T>(Func<IRequest, IResponse, T, Task> filterFn)
Parameters
TypeName
System.Func<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>,System.Threading.Tasks.Task>filterFn
Type Parameters
  • T

RegisterTypedResponseFilter<T>(Func<Container, ITypedFilter<T>>)

Register Typed Service Response Filter

View Source
Declaration
public void RegisterTypedResponseFilter<T>(Func<Container, ITypedFilter<T>> filter)
Parameters
TypeName
System.Func<Funq.Container,ServiceStack.Host.ITypedFilter<<T>>>filter
Type Parameters
  • T

RegisterTypedResponseFilterAsync<T>(Func<Container, ITypedFilterAsync<T>>)

Register Async Typed Service Response Filter

View Source
Declaration
public void RegisterTypedResponseFilterAsync<T>(Func<Container, ITypedFilterAsync<T>> filter)
Parameters
TypeName
System.Func<Funq.Container,ServiceStack.Host.ITypedFilterAsync<<T>>>filter
Type Parameters
  • T

RegisterTypedMessageRequestFilter<T>(Action<IRequest, IResponse, T>)

Register Typed MQ Request Filter

View Source
Declaration
public void RegisterTypedMessageRequestFilter<T>(Action<IRequest, IResponse, T> filterFn)
Parameters
TypeName
System.Action<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>>filterFn
Type Parameters
  • T

RegisterTypedMessageResponseFilter<T>(Action<IRequest, IResponse, T>)

Register Typed MQ Response Filter

View Source
Declaration
public void RegisterTypedMessageResponseFilter<T>(Action<IRequest, IResponse, T> filterFn)
Parameters
TypeName
System.Action<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>>filterFn
Type Parameters
  • T

MapProjectPath(String)

Override to customize the physical path to return for this relativePath

View Source
Declaration
public virtual string MapProjectPath(string relativePath)
Returns

System.String

Parameters
TypeName
System.StringrelativePath

ResolvePathInfo(IRequest, String)

Override to customize normalized /path/info to use for this request

View Source
Declaration
public virtual string ResolvePathInfo(IRequest request, string originalPathInfo)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestrequest
System.StringoriginalPathInfo

NormalizePathInfo(String, String)

Normalizes /path/info based on Config.HandlerFactoryPath

View Source
Declaration
public static string NormalizePathInfo(string pathInfo, string mode)
Returns

System.String

Parameters
TypeName
System.StringpathInfo
System.Stringmode

ReturnRedirectHandler(IHttpRequest)

Override to customize Redirect Responses

View Source
Declaration
public virtual IHttpHandler ReturnRedirectHandler(IHttpRequest httpReq)
Returns

System.Web.IHttpHandler

Parameters
TypeName
ServiceStack.Web.IHttpRequesthttpReq

ReturnRequestInfoHandler(IHttpRequest)

Override to customize IHttpHandler used to service ?debug=requestinfo requests

View Source
Declaration
public virtual IHttpHandler ReturnRequestInfoHandler(IHttpRequest httpReq)
Returns

System.Web.IHttpHandler

Parameters
TypeName
ServiceStack.Web.IHttpRequesthttpReq

OnApplicationStarted()

View Source
Declaration
public virtual void OnApplicationStarted()

OnApplicationStopping()

View Source
Declaration
public virtual void OnApplicationStopping()

Dispose(Boolean)

Executes OnDisposeCallbacks and Disposes IDisposable's dependencies in the IOC & reset singleton states

View Source
Declaration
protected virtual void Dispose(bool disposing)
Parameters
TypeName
System.Booleandisposing

Dispose()

View Source
Declaration
public void Dispose()

Finalize()

View Source
Declaration
protected void Finalize()

ApplyRequestConvertersAsync(IRequest, Object)

Executes Service Request Converters

View Source
Declaration
public async Task<object> ApplyRequestConvertersAsync(IRequest req, object requestDto)
Returns

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

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.ObjectrequestDto

ApplyResponseConvertersAsync(IRequest, Object)

Executes Service Response Converters

View Source
Declaration
public async Task<object> ApplyResponseConvertersAsync(IRequest req, object responseDto)
Returns

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

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.ObjectresponseDto

ApplyCustomHandlerRequestFilters(IRequest, IResponse)

Apply PreRequest Filters for participating Custom Handlers, e.g. RazorFormat, MarkdownFormat, etc

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

System.Boolean

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

ApplyPreAuthenticateFiltersAsync(IRequest, IResponse)

Apply PreAuthenticate Filters from IAuthWithRequest AuthProviders

View Source
Declaration
public virtual async Task ApplyPreAuthenticateFiltersAsync(IRequest httpReq, IResponse httpRes)
Returns

System.Threading.Tasks.Task

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

ApplyPreRequestFilters(IRequest, IResponse)

Applies the raw request filters. Returns whether or not the request has been handled and no more processing should be done.

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

System.Boolean

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

ApplyRequestFilters(IRequest, IResponse, Object)

View Source
Declaration
[Obsolete("Use ApplyRequestFiltersAsync")]
public bool ApplyRequestFilters(IRequest req, IResponse res, object requestDto)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto

ApplyRequestFiltersAsync(IRequest, IResponse, Object)

Applies the request filters. Returns whether or not the request has been handled and no more processing should be done.

View Source
Declaration
public async Task ApplyRequestFiltersAsync(IRequest req, IResponse res, object requestDto)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto

ApplyRequestFiltersSingleAsync(IRequest, IResponse, Object)

Executes Service Request Filters

View Source
Declaration
protected async Task ApplyRequestFiltersSingleAsync(IRequest req, IResponse res, object requestDto)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto

ApplyResponseFilters(IRequest, IResponse, Object)

View Source
Declaration
[Obsolete("Use ApplyResponseFiltersAsync")]
public bool ApplyResponseFilters(IRequest req, IResponse res, object response)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.Objectresponse

ApplyResponseFiltersAsync(IRequest, IResponse, Object)

Applies the response filters. Returns whether or not the request has been handled and no more processing should be done.

View Source
Declaration
public async Task ApplyResponseFiltersAsync(IRequest req, IResponse res, object response)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.Objectresponse

ApplyResponseFiltersSingleAsync(IRequest, IResponse, Object)

Executes Service Response Filters

View Source
Declaration
protected async Task ApplyResponseFiltersSingleAsync(IRequest req, IResponse res, object response)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.Objectresponse

ApplyMessageRequestFilters(IRequest, IResponse, Object)

Executes MQ Response Filters

View Source
Declaration
public bool ApplyMessageRequestFilters(IRequest req, IResponse res, object requestDto)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.ObjectrequestDto

ApplyMessageResponseFilters(IRequest, IResponse, Object)

Executes MQ Response Filters

View Source
Declaration
public bool ApplyMessageResponseFilters(IRequest req, IResponse res, object response)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.Objectresponse

ApplyGatewayRequestFiltersAsync(IRequest, Object)

Execute Service Gateway Request Filters

View Source
Declaration
public async Task<bool> ApplyGatewayRequestFiltersAsync(IRequest req, object request)
Returns

System.Threading.Tasks.Task<System.Boolean>

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.Objectrequest

ApplyGatewayRespoonseFiltersAsync(IRequest, Object)

Execute Service Gateway Response Filters

View Source
Declaration
public async Task<bool> ApplyGatewayRespoonseFiltersAsync(IRequest req, object responseDto)
Returns

System.Threading.Tasks.Task<System.Boolean>

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.ObjectresponseDto

ExecTypedFilters(Dictionary<Type, ITypedFilter>, IRequest, IResponse, Object)

Executes Typed Request Filters

View Source
Declaration
public void ExecTypedFilters(Dictionary<Type, ITypedFilter> typedFilters, IRequest req, IResponse res, object dto)
Parameters
TypeName
System.Collections.Generic.Dictionary<System.Type,ServiceStack.Host.ITypedFilter>typedFilters
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.Objectdto

ExecTypedFiltersAsync(Dictionary<Type, ITypedFilterAsync>, IRequest, IResponse, Object)

Executes Typed Request Filters

View Source
Declaration
public async Task ExecTypedFiltersAsync(Dictionary<Type, ITypedFilterAsync> typedFilters, IRequest req, IResponse res, object dto)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
System.Collections.Generic.Dictionary<System.Type,ServiceStack.Host.ITypedFilterAsync>typedFilters
ServiceStack.Web.IRequestreq
ServiceStack.Web.IResponseres
System.Objectdto

GetDefaultSessionExpiry(IRequest)

Return the Default Session Expiry for this Request

View Source
Declaration
public virtual TimeSpan GetDefaultSessionExpiry(IRequest req)
Returns

System.TimeSpan

Parameters
TypeName
ServiceStack.Web.IRequestreq

HasFeature(Feature)

Return whether this App supports this feature

View Source
Declaration
public bool HasFeature(Feature feature)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Featurefeature

AssertFeatures(Feature)

Assert whether this App supports this feature

View Source
Declaration
public void AssertFeatures(Feature usesFeatures)
Parameters
TypeName
ServiceStack.FeatureusesFeatures

AssertContentType(String)

Assert whether this App should server this contentType

View Source
Declaration
public void AssertContentType(string contentType)
Parameters
TypeName
System.StringcontentType

HasAccessToMetadata(IRequest, IResponse)

Override to return whether this request can access the metadata for the request

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

System.Boolean

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

HandleErrorResponse(IRequest, IResponse, HttpStatusCode, String)

Override to handle Forbidden Feature Error Responses

View Source
Declaration
public void HandleErrorResponse(IRequest httpReq, IResponse httpRes, HttpStatusCode errorStatus, string errorStatusDescription = null)
Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Web.IResponsehttpRes
System.Net.HttpStatusCodeerrorStatus
System.StringerrorStatusDescription

GetCustomErrorHandler(Int32)

Override to customize the IServiceStackHandler that should handle the specified errorStatusCode

View Source
Declaration
public IServiceStackHandler GetCustomErrorHandler(int errorStatusCode)
Returns

ServiceStack.Host.Handlers.IServiceStackHandler

Parameters
TypeName
System.Int32errorStatusCode

GetCustomErrorHandler(HttpStatusCode)

Override to customize the IServiceStackHandler that should handle the specified HttpStatusCode

View Source
Declaration
public IServiceStackHandler GetCustomErrorHandler(HttpStatusCode errorStatus)
Returns

ServiceStack.Host.Handlers.IServiceStackHandler

Parameters
TypeName
System.Net.HttpStatusCodeerrorStatus

GetNotFoundHandler()

Override to change the IServiceStackHandler that should handle 404 NotFount Responses

View Source
Declaration
public IServiceStackHandler GetNotFoundHandler()
Returns

ServiceStack.Host.Handlers.IServiceStackHandler

GetCustomErrorHttpHandler(HttpStatusCode)

Override to customize the IHttpHandler that should handle the specified HttpStatusCode

View Source
Declaration
public IHttpHandler GetCustomErrorHttpHandler(HttpStatusCode errorStatus)
Returns

System.Web.IHttpHandler

Parameters
TypeName
System.Net.HttpStatusCodeerrorStatus

HasValidAuthSecret(IRequest)

Return true if the current request is configured with the super user AdminAuthSecret or not

View Source
Declaration
public bool HasValidAuthSecret(IRequest httpReq)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq

CreateErrorResponse(Exception, Object)

Override to customize converting an Exception into a generic ErrorResponse DTO

View Source
Declaration
public virtual ErrorResponse CreateErrorResponse(Exception ex, object request = null)
Returns

ServiceStack.ErrorResponse

Parameters
TypeName
System.Exceptionex
System.Objectrequest

CreateResponseStatus(Exception, Object)

Override to customize converting an Exception into the ResponseStatus DTO

View Source
Declaration
public virtual ResponseStatus CreateResponseStatus(Exception ex, object request = null)
Returns

ServiceStack.ResponseStatus

Parameters
TypeName
System.Exceptionex
System.Objectrequest

UseException(Exception)

Return the Exception to use when creating the Error Response DTO and ResponseStatus

View Source
Declaration
public Exception UseException(Exception ex)
Returns

System.Exception

Parameters
TypeName
System.Exceptionex

OnLogError(Type, String, Exception)

Callback for handling when errors are logged, also called for non-Exception error logging like 404 requests

View Source
Declaration
public virtual void OnLogError(Type type, string message, Exception innerEx = null)
Parameters
TypeName
System.Typetype
System.Stringmessage
System.ExceptioninnerEx

TryGetUserId(IRequest)

Try infer UserId from IRequest

View Source
Declaration
public virtual string TryGetUserId(IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq

OnExceptionTypeFilter(Exception, ResponseStatus)

Override to intercept & customize Exception responses

View Source
Declaration
public virtual void OnExceptionTypeFilter(Exception ex, ResponseStatus responseStatus)
Parameters
TypeName
System.Exceptionex
ServiceStack.ResponseStatusresponseStatus

OnSaveSession(IRequest, IAuthSession, Nullable<TimeSpan>)

Override to intercept when Sessions using sync APIs are saved

View Source
Declaration
[Obsolete("Use OnSaveSessionAsync")]
public virtual void OnSaveSession(IRequest httpReq, IAuthSession session, TimeSpan? expiresIn = null)
Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Auth.IAuthSessionsession
System.Nullable<System.TimeSpan>expiresIn

OnSaveSessionAsync(IRequest, IAuthSession, Nullable<TimeSpan>, CancellationToken)

Override to intercept when Sessions using async APIs are saved

View Source
Declaration
public virtual Task OnSaveSessionAsync(IRequest httpReq, IAuthSession session, TimeSpan? expiresIn = null, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequesthttpReq
ServiceStack.Auth.IAuthSessionsession
System.Nullable<System.TimeSpan>expiresIn
System.Threading.CancellationTokentoken

OnSessionFilter(IRequest, IAuthSession, String)

Inspect or modify ever new UserSession created or resolved from cache. return null if Session is invalid to create new Session.

View Source
Declaration
public virtual IAuthSession OnSessionFilter(IRequest req, IAuthSession session, string withSessionId)
Returns

ServiceStack.Auth.IAuthSession

Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Auth.IAuthSessionsession
System.StringwithSessionId

HttpCookieFilter(HttpCookie)

View Source
Declaration
public virtual void HttpCookieFilter(HttpCookie cookie)
Parameters
TypeName
System.Web.HttpCookiecookie

Override built-in Cookies, return false to prevent the Cookie from being set.

View Source
Declaration
public virtual bool SetCookieFilter(IRequest req, Cookie cookie)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.Net.Cookiecookie

AllowSetCookie(IRequest, String)

View Source
Declaration
[Obsolete("Override SetCookieFilter")]
protected virtual bool AllowSetCookie(IRequest req, string cookieName)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.StringcookieName

TryGetCurrentRequest()

Overriden by AppHost's to return the current IRequest if it supports singleton access to the Request Context

View Source
Declaration
public virtual IRequest TryGetCurrentRequest()
Returns

ServiceStack.Web.IRequest

OnAfterExecute(IRequest, Object, Object)

Override to intercept the response of a ServiceStack Service request

View Source
Declaration
public virtual object OnAfterExecute(IRequest req, object requestDto, object response)
Returns

System.Object

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.ObjectrequestDto
System.Objectresponse

GetTypesConfigForMetadata(IRequest)

Override to customize what DTOs are displayed on metadata pages

View Source
Declaration
public virtual MetadataTypesConfig GetTypesConfigForMetadata(IRequest req)
Returns

ServiceStack.MetadataTypesConfig

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetDbConnection(IRequest)

Gets IDbConnection Checks if DbInfo is seat in RequestContext. See multitenancy: https://docs.servicestack.net/multitenancy Called by itself, ServiceStack.Service and ViewPageBase

View Source
Declaration
public virtual IDbConnection GetDbConnection(IRequest req = null)
Returns

System.Data.IDbConnection

Parameters
TypeNameDescription
ServiceStack.Web.IRequestreqProvided by services and pageView, can be helpful when overriding this method

|

GetDbConnection(String)

View Source
Declaration
public virtual IDbConnection GetDbConnection(string namedConnection)
Returns

System.Data.IDbConnection

Parameters
TypeName
System.StringnamedConnection

GetDbNamedConnection(IRequest)

View Source
Declaration
public virtual string GetDbNamedConnection(IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetRedisClient(IRequest)

Resolves ServiceStack.Redis.IRedisClient based on ServiceStack.Redis.IRedisClientsManager.GetClient(); Called by itself, ServiceStack.Service and ViewPageBase

View Source
Declaration
public virtual IRedisClient GetRedisClient(IRequest req = null)
Returns

ServiceStack.Redis.IRedisClient

Parameters
TypeNameDescription
ServiceStack.Web.IRequestreqProvided by services and pageView, can be helpful when overriding this method

|

GetRedisClientAsync(IRequest)

Resolves ServiceStack.Redis.IRedisClient based on ServiceStack.Redis.IRedisClientsManager.GetClient(); Called by itself, ServiceStack.Service and ViewPageBase

View Source
Declaration
public virtual ValueTask<IRedisClientAsync> GetRedisClientAsync(IRequest req = null)
Returns

ValueTask<ServiceStack.Redis.IRedisClientAsync>

Parameters
TypeNameDescription
ServiceStack.Web.IRequestreqProvided by services and pageView, can be helpful when overriding this method

|

GetCacheClient(IRequest)

Tries to resolve ServiceStack.Caching.ICacheClient through IoC container. If not registered, it falls back to ServiceStack.Redis.IRedisClientsManager.GetClient(), otherwise returns DefaultCache MemoryCacheClient

View Source
Declaration
public virtual ICacheClient GetCacheClient(IRequest req = null)
Returns

ServiceStack.Caching.ICacheClient

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetCacheClientAsync(IRequest)

Get registered ICacheClientAsync otherwise returns async wrapped sync ICacheClient

View Source
Declaration
public virtual ICacheClientAsync GetCacheClientAsync(IRequest req = null)
Returns

ServiceStack.Caching.ICacheClientAsync

Parameters
TypeName
ServiceStack.Web.IRequestreq

TryGetNativeCacheClient(IRequest, out ICacheClient, out ICacheClientAsync)

Only sets cacheAsync if native Async provider, otherwise sets cacheSync

View Source
Declaration
public virtual void TryGetNativeCacheClient(IRequest req, out ICacheClient cacheSync, out ICacheClientAsync cacheAsync)
Parameters
TypeName
ServiceStack.Web.IRequestreq
ServiceStack.Caching.ICacheClientcacheSync
ServiceStack.Caching.ICacheClientAsynccacheAsync

GetMemoryCacheClient(IRequest)

Returns ServiceStack.Caching.MemoryCacheClient. cache is only persisted for this running app instance. Called by ServiceStack.Service.MemoryCacheClient

View Source
Declaration
public virtual MemoryCacheClient GetMemoryCacheClient(IRequest req = null)
Returns

ServiceStack.Caching.MemoryCacheClient: Nullable MemoryCacheClient

Parameters
TypeNameDescription
ServiceStack.Web.IRequestreqProvided by services and pageView, can be helpful when overriding this method

|

GetMessageProducer(IRequest)

Returns ServiceStack.Messaging.IMessageProducer from the IOC container. Called by itself, ServiceStack.Service and ViewPageBase

View Source
Declaration
public virtual IMessageProducer GetMessageProducer(IRequest req = null)
Returns

ServiceStack.Messaging.IMessageProducer

Parameters
TypeNameDescription
ServiceStack.Web.IRequestreqProvided by services and PageViewBase, can be helpful when overriding this method

|

GetServiceGateway()

Get the configured ServiceStack.IServiceGateway

View Source
Declaration
public virtual IServiceGateway GetServiceGateway()
Returns

ServiceStack.IServiceGateway

GetServiceGateway(IRequest)

Get the configured ServiceStack.IServiceGateway for this request.

View Source
Declaration
public virtual IServiceGateway GetServiceGateway(IRequest req)
Returns

ServiceStack.IServiceGateway

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetAuthRepository(IRequest)

Gets the registered ServiceStack.Auth.IAuthRepository

View Source
Declaration
public virtual IAuthRepository GetAuthRepository(IRequest req = null)
Returns

ServiceStack.Auth.IAuthRepository

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetAuthRepositoryAsync(IRequest)

Gets the registered ServiceStack.Auth.IAuthRepositoryAsync Returns native IAuthRepositoryAsync if exists, a sync wrapper if IAuthRepository exists, otherwise null.

View Source
Declaration
public virtual IAuthRepositoryAsync GetAuthRepositoryAsync(IRequest req = null)
Returns

ServiceStack.Auth.IAuthRepositoryAsync

Parameters
TypeName
ServiceStack.Web.IRequestreq

AssertAuthenticated(IAuthSession, IRequest)

Default logic to determine whether a Session is Authenticated

View Source
Declaration
public virtual IAuthSession AssertAuthenticated(IAuthSession session, IRequest req = null)
Returns

ServiceStack.Auth.IAuthSession

Parameters
TypeName
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Web.IRequestreq

GetCookies(IHttpResponse)

Return the ICookies implementation to use

View Source
Declaration
public virtual ICookies GetCookies(IHttpResponse res)
Returns

ServiceStack.Web.ICookies

Parameters
TypeName
ServiceStack.Web.IHttpResponseres

ShouldCompressFile(IVirtualFile)

Override to return whether static files should be sent compressed or not (if supported by UserAgent)

View Source
Declaration
public virtual bool ShouldCompressFile(IVirtualFile file)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.IO.IVirtualFilefile

GetRuntimeConfig<T>(IRequest, String, T)

Allow overriding ServiceStack runtime config like JWT Keys

View Source
Declaration
public virtual T GetRuntimeConfig<T>(IRequest req, string name, T defaultValue)
Returns

<T>

Parameters
TypeName
ServiceStack.Web.IRequestreq
System.Stringname
<T>defaultValue
Type Parameters
  • T

PublishMessage<T>(IMessageProducer, T)

Override to intercept MQ Publish Requests

View Source
Declaration
public virtual void PublishMessage<T>(IMessageProducer messageProducer, T message)
Parameters
TypeName
ServiceStack.Messaging.IMessageProducermessageProducer
<T>message
Type Parameters
  • T

WriteAutoHtmlResponseAsync(IRequest, Object, String, Stream)

Override to intercept auto HTML Page Response

View Source
Declaration
public virtual async Task WriteAutoHtmlResponseAsync(IRequest request, object response, string html, Stream outputStream)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Web.IRequestrequest
System.Objectresponse
System.Stringhtml
System.IO.StreamoutputStream

GetMetadataPluginIds()

Override to alter what registered plugins you want discoverable (used by ServiceStack Studio to enable features).

View Source
Declaration
public virtual List<string> GetMetadataPluginIds()
Returns

System.Collections.Generic.List<System.String>

GetAuthorization(IRequest)

Override Authorization Header resolution

View Source
Declaration
public virtual string GetAuthorization(IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetBearerToken(IRequest)

Override Authorization Bearer Token resolution

View Source
Declaration
public virtual string GetBearerToken(IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetJwtToken(IRequest)

Override JWT Token resolution

View Source
Declaration
public virtual string GetJwtToken(IRequest req)
Returns

System.String

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetRefreshToken(IRequest)

Override Authorization Refresh Token resolution