IAppHost
ASP.NET or HttpListener ServiceStack host
Assembly: ServiceStack.dll
View Source
public interface IAppHost : IResolver
Properties
PathBase
The base path ServiceStack is hosted on
View Source
string PathBase { get; }
ServiceAssemblies
The assemblies reflected to find api services provided in the AppHost constructor
View Source
List<Assembly> ServiceAssemblies { get; }
OnEndRequestCallbacks
Register callbacks to be called at the end of each request.
View Source
List<Action<IRequest>> OnEndRequestCallbacks { get; }
Routes
Register user-defined custom routes.
View Source
IServiceRoutes Routes { get; }
Metadata
Inferred Metadata available from existing services
View Source
ServiceMetadata Metadata { get; }
ContentTypes
Register custom ContentType serializers
View Source
IContentTypes ContentTypes { get; }
PreRequestFilters
Add Request Filters, to be applied before the dto is deserialized
View Source
List<Action<IRequest, IResponse>> PreRequestFilters { get; }
RequestConverters
Add Request Converter to convert Request DTO's
View Source
List<Func<IRequest, object, Task<object>>> RequestConverters { get; }
ResponseConverters
Add Response Converter to convert Response DTO's
View Source
List<Func<IRequest, object, Task<object>>> ResponseConverters { get; }
GlobalRequestFilters
Add Request Filters for HTTP Requests
View Source
List<Action<IRequest, IResponse, object>> GlobalRequestFilters { get; }
GlobalRequestFiltersAsync
Add Async Request Filters for HTTP Requests
View Source
List<Func<IRequest, IResponse, object, Task>> GlobalRequestFiltersAsync { get; }
GlobalResponseFilters
Add Response Filters for HTTP Responses
View Source
List<Action<IRequest, IResponse, object>> GlobalResponseFilters { get; }
GlobalResponseFiltersAsync
Add Async Response Filters for HTTP Responses
View Source
List<Func<IRequest, IResponse, object, Task>> GlobalResponseFiltersAsync { get; set; }
GlobalMessageRequestFilters
Add Request Filters for MQ/TCP Requests
View Source
List<Action<IRequest, IResponse, object>> GlobalMessageRequestFilters { get; }
GlobalMessageRequestFiltersAsync
Add Async Request Filters for MQ/TCP Requests
View Source
List<Func<IRequest, IResponse, object, Task>> GlobalMessageRequestFiltersAsync { get; }
GlobalMessageResponseFilters
Add Response Filters for MQ/TCP Responses
View Source
List<Action<IRequest, IResponse, object>> GlobalMessageResponseFilters { get; }
GlobalMessageResponseFiltersAsync
Add Async Response Filters for MQ/TCP Responses
View Source
List<Func<IRequest, IResponse, object, Task>> GlobalMessageResponseFiltersAsync { get; }
GatewayRequestFilters
Add Request Filter for Service Gateway Requests
View Source
List<Action<IRequest, object>> GatewayRequestFilters { get; }
GatewayRequestFiltersAsync
Add Async Request Filter for Service Gateway Requests
View Source
List<Func<IRequest, object, Task>> GatewayRequestFiltersAsync { get; }
GatewayResponseFilters
Add Response Filter for Service Gateway Responses
View Source
List<Action<IRequest, object>> GatewayResponseFilters { get; }
GatewayResponseFiltersAsync
Add Async Response Filter for Service Gateway Responses
View Source
List<Func<IRequest, object, Task>> GatewayResponseFiltersAsync { get; }
ViewEngines
Add alternative HTML View Engines
View Source
List<IViewEngine> ViewEngines { get; }
ServiceExceptionHandlers
Provide an exception handler for unhandled exceptions
View Source
List<HandleServiceExceptionDelegate> ServiceExceptionHandlers { get; }
ServiceExceptionHandlersAsync
Provide an exception handler for unhandled exceptions (Async)
View Source
List<HandleServiceExceptionAsyncDelegate> ServiceExceptionHandlersAsync { get; }
UncaughtExceptionHandlers
Provide an exception handler for un-caught exceptions
View Source
List<HandleUncaughtExceptionDelegate> UncaughtExceptionHandlers { get; }
UncaughtExceptionHandlersAsync
Provide an exception handler for un-caught exceptions (Async)
View Source
List<HandleUncaughtExceptionAsyncDelegate> UncaughtExceptionHandlersAsync { get; }
GatewayExceptionHandlers
Provide an exception handler for Service Gateway Exceptions
View Source
List<HandleGatewayExceptionDelegate> GatewayExceptionHandlers { get; }
GatewayExceptionHandlersAsync
Provide an exception handler for Service Gateway Exceptions (Async)
View Source
List<HandleGatewayExceptionAsyncDelegate> GatewayExceptionHandlersAsync { get; }
BeforeConfigure
Register callbacks fired just before AppHost.Configure()
View Source
List<Action<ServiceStackHost>> BeforeConfigure { get; set; }
AfterConfigure
Register callbacks fired just after AppHost.Configure()
View Source
List<Action<ServiceStackHost>> AfterConfigure { get; set; }
AfterPluginsLoaded
Register callbacks to be fired after all plugins are loaded
View Source
List<Action<ServiceStackHost>> AfterPluginsLoaded { get; set; }
AfterInitCallbacks
Register callbacks to be fired after the AppHost has finished initializing
View Source
List<Action<IAppHost>> AfterInitCallbacks { get; }
OnDisposeCallbacks
Register callbacks to be fired when AppHost is being disposed
View Source
List<Action<IAppHost>> OnDisposeCallbacks { get; }
RawHttpHandlers
Skip the ServiceStack Request Pipeline and process the returned IHttpHandler instead
View Source
List<Func<IHttpRequest, IHttpHandler>> RawHttpHandlers { get; }
CatchAllHandlers
Provide a catch-all handler that doesn't match any routes
View Source
List<HttpHandlerResolverDelegate> CatchAllHandlers { get; }
FallbackHandlers
Provide a fallback handler for not found requests (last filter in Request Pipeline)
View Source
List<HttpHandlerResolverDelegate> FallbackHandlers { get; }
GlobalHtmlErrorHttpHandler
Use a fall-back Error Handler for handling global errors
View Source
IServiceStackHandler GlobalHtmlErrorHttpHandler { get; }
CustomErrorHttpHandlers
Use a Custom Error Handler for handling specific error HttpStatusCodes
View Source
Dictionary<HttpStatusCode, IServiceStackHandler> CustomErrorHttpHandlers { get; }
RequestBinders
Provide a custom model minder for a specific Request DTO
View Source
Dictionary<Type, Func<IRequest, object>> RequestBinders { get; }
Config
The AppHost config
View Source
HostConfig Config { get; }
AppSettings
The AppHost AppSettings. Defaults to App or Web.config appSettings.
View Source
IAppSettings AppSettings { get; }
Plugins
List of pre-registered and user-defined plugins to be enabled in this AppHost
View Source
List<IPlugin> Plugins { get; }
VirtualFileSources
Cascading number of file sources, inc. Embedded Resources, File System, In Memory, S3
View Source
IVirtualPathProvider VirtualFileSources { get; set; }
VirtualFiles
Read/Write Virtual FileSystem. Defaults to FileSystemVirtualPathProvider
View Source
IVirtualFiles VirtualFiles { get; set; }
RootDirectory
The WebRoot VFS Directory of the cascading VirtualFileSources
View Source
IVirtualDirectory RootDirectory { get; }
ContentRootDirectory
The ContentRoot VFS Directory of the read/write VirtualFiles Provider
View Source
IVirtualDirectory ContentRootDirectory { get; }
InsertVirtualFileSources
Insert Virtual File Sources at the beginning so they take precedence over built-in sources
View Source
List<IVirtualPathProvider> InsertVirtualFileSources { get; set; }
AddVirtualFileSources
Add additional Virtual File Sources at the end after built-in Virtual File Sources
View Source
List<IVirtualPathProvider> AddVirtualFileSources { get; }
ServiceController
Access Service Controller for ServiceStack
View Source
ServiceController ServiceController { get; }
ScriptContext
Global #Script ScriptContext for AppHost. Returns SharpPagesFeature plugin or fallsback to DefaultScriptContext.
View Source
ScriptContext ScriptContext { get; }
Methods
Register<T>(T)
Register dependency in AppHost IOC on Startup
View Source
void Register<T>(T instance)
Parameters
Type | Name |
---|---|
<T> | instance |
Type Parameters
T
RegisterAs<T, TAs>()
AutoWired Registration of an interface with a concrete type in AppHost IOC on Startup.
View Source
void RegisterAs<T, TAs>()
where T : TAs
Type Parameters
T
TAs
Release(Object)
Allows the clean up for executed autowired services and filters. Calls directly after services and filters are executed.
View Source
void Release(object instance)
Parameters
Type | Name |
---|---|
System.Object | instance |
OnEndRequest(IRequest)
Called at the end of each request. Enables Request Scope.
View Source
void OnEndRequest(IRequest request = null)
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | request |
RegisterTypedRequestFilter<T>(Action<IRequest, IResponse, T>)
Add Request Filter for a specific Request DTO Type
View Source
void RegisterTypedRequestFilter<T>(Action<IRequest, IResponse, T> filterFn)
Parameters
Type | Name |
---|---|
System.Action<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>> | filterFn |
Type Parameters
T
RegisterTypedRequestFilterAsync<T>(Func<IRequest, IResponse, T, Task>)
Add an Async Request Filter for a specific Request DTO Type
View Source
void RegisterTypedRequestFilterAsync<T>(Func<IRequest, IResponse, T, Task> filterFn)
Parameters
Type | Name |
---|---|
System.Func<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>,System.Threading.Tasks.Task> | filterFn |
Type Parameters
T
RegisterTypedRequestFilter<T>(Func<Container, ITypedFilter<T>>)
Add ServiceStack.Host.ITypedFilter%601
as a Typed Request Filter for a specific Request DTO Type
View Source
void RegisterTypedRequestFilter<T>(Func<Container, ITypedFilter<T>> filter)
Parameters
Type | Name | Description |
---|---|---|
System.Func<Funq.Container,ServiceStack.Host.ITypedFilter<<T>>> | filter | The Funq.Container methods to resolve the ServiceStack.Host.ITypedFilter%601 . |
|
Type Parameters
Name | Description |
---|---|
T | The DTO Type. |
RegisterTypedRequestFilterAsync<T>(Func<Container, ITypedFilterAsync<T>>)
Add ServiceStack.Host.ITypedFilterAsync%601
as an Async Typed Request Filter for a specific Request DTO Type
View Source
void RegisterTypedRequestFilterAsync<T>(Func<Container, ITypedFilterAsync<T>> filter)
Parameters
Type | Name | Description |
---|---|---|
System.Func<Funq.Container,ServiceStack.Host.ITypedFilterAsync<<T>>> | filter | The Funq.Container methods to resolve the ServiceStack.Host.ITypedFilterAsync%601 . |
|
Type Parameters
Name | Description |
---|---|
T | The DTO Type. |
RegisterTypedResponseFilter<T>(Action<IRequest, IResponse, T>)
Add Request Filter for a specific Response DTO Type
View Source
void RegisterTypedResponseFilter<T>(Action<IRequest, IResponse, T> filterFn)
Parameters
Type | Name |
---|---|
System.Action<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>> | filterFn |
Type Parameters
T
RegisterTypedResponseFilterAsync<T>(Func<IRequest, IResponse, T, Task>)
Add an Async Request Filter for a specific Response DTO Type
View Source
void RegisterTypedResponseFilterAsync<T>(Func<IRequest, IResponse, T, Task> filterFn)
Parameters
Type | Name |
---|---|
System.Func<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>,System.Threading.Tasks.Task> | filterFn |
Type Parameters
T
RegisterTypedResponseFilter<T>(Func<Container, ITypedFilter<T>>)
Add ServiceStack.Host.ITypedFilter%601
as a Typed Request Filter for a specific Request DTO Type
View Source
void RegisterTypedResponseFilter<T>(Func<Container, ITypedFilter<T>> filter)
Parameters
Type | Name | Description |
---|---|---|
System.Func<Funq.Container,ServiceStack.Host.ITypedFilter<<T>>> | filter | The Funq.Container methods to resolve the ServiceStack.Host.ITypedFilter%601 . |
|
Type Parameters
Name | Description |
---|---|
T | The DTO Type. |
RegisterTypedResponseFilterAsync<T>(Func<Container, ITypedFilterAsync<T>>)
Add ServiceStack.Host.ITypedFilterAsync%601
as an Async Typed Request Filter for a specific Request DTO Type
View Source
void RegisterTypedResponseFilterAsync<T>(Func<Container, ITypedFilterAsync<T>> filter)
Parameters
Type | Name | Description |
---|---|---|
System.Func<Funq.Container,ServiceStack.Host.ITypedFilterAsync<<T>>> | filter | The Funq.Container methods to resolve the ServiceStack.Host.ITypedFilterAsync%601 . |
|
Type Parameters
Name | Description |
---|---|
T | The DTO Type. |
RegisterTypedMessageRequestFilter<T>(Action<IRequest, IResponse, T>)
Add Request Filter for a specific MQ Request DTO Type
View Source
void RegisterTypedMessageRequestFilter<T>(Action<IRequest, IResponse, T> filterFn)
Parameters
Type | Name |
---|---|
System.Action<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>> | filterFn |
Type Parameters
T
RegisterTypedMessageResponseFilter<T>(Action<IRequest, IResponse, T>)
Add Request Filter for a specific MQ Response DTO Type
View Source
void RegisterTypedMessageResponseFilter<T>(Action<IRequest, IResponse, T> filterFn)
Parameters
Type | Name |
---|---|
System.Action<ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,<T>> | filterFn |
Type Parameters
T
GetRuntimeConfig<T>(IRequest, String, T)
Allow specific configuration to be overridden at runtime in multi-tenancy Applications by overriding GetRuntimeConfig in your AppHost
View Source
T GetRuntimeConfig<T>(IRequest req, string name, T defaultValue)
Returns
<T>
Parameters
Type | Name |
---|---|
ServiceStack.Web.IRequest | req |
System.String | name |
<T> | defaultValue |
Type Parameters
T
RegisterService(Type, String[])
Register an Adhoc web service on Startup
View Source
void RegisterService(Type serviceType, params string[] atRestPaths)
Parameters
Type | Name |
---|---|
System.Type | serviceType |
System.String[] | atRestPaths |
RegisterServicesInAssembly(Assembly)
Register all Services in Assembly
View Source
void RegisterServicesInAssembly(Assembly assembly)
Parameters
Type | Name |
---|---|
System.Reflection.Assembly | assembly |
LoadPlugin(IPlugin[])
Apply plugins to this AppHost
View Source
void LoadPlugin(params IPlugin[] plugins)
Parameters
Type | Name |
---|---|
ServiceStack.IPlugin[] | plugins |
MapProjectPath(String)
Returns the Absolute File Path, relative from your AppHost's Project Path
View Source
string MapProjectPath(string relativePath)
Returns
System.String
Parameters
Type | Name |
---|---|
System.String | relativePath |
CreateServiceRunner<TRequest>(ActionContext)
Create a service runner for IService actions
View Source
IServiceRunner<TRequest> CreateServiceRunner<TRequest>(ActionContext actionContext)
Returns
ServiceStack.Web.IServiceRunner<TRequest>
Parameters
Type | Name |
---|---|
ServiceStack.Host.ActionContext | actionContext |
Type Parameters
TRequest
ResolveAbsoluteUrl(String, IRequest)
Resolve the absolute url for this request
View Source
string ResolveAbsoluteUrl(string virtualPath, IRequest httpReq)
Returns
System.String
Parameters
Type | Name |
---|---|
System.String | virtualPath |
ServiceStack.Web.IRequest | httpReq |
ResolveLocalizedString(String, IRequest)
Resolve localized text, returns itself by default. The Request is provided when exists.
View Source
string ResolveLocalizedString(string text, IRequest request)
Returns
System.String
Parameters
Type | Name |
---|---|
System.String | text |
ServiceStack.Web.IRequest | request |
ExecuteMessage(IMessage)
Execute MQ Message in ServiceStack
View Source
object ExecuteMessage(IMessage mqMessage)
Returns
System.Object
Parameters
Type | Name |
---|---|
ServiceStack.Messaging.IMessage | mqMessage |
ExecuteMessageAsync(IMessage, CancellationToken)
Execute MQ Message in ServiceStack
View Source
Task<object> ExecuteMessageAsync(IMessage mqMessage, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Object>
Parameters
Type | Name |
---|---|
ServiceStack.Messaging.IMessage | mqMessage |
System.Threading.CancellationToken | token |
PublishMessage<T>(IMessageProducer, T)
Publish Message to be processed by AppHost
View Source
void PublishMessage<T>(IMessageProducer messageProducer, T message)
Parameters
Type | Name |
---|---|
ServiceStack.Messaging.IMessageProducer | messageProducer |
<T> | message |
Type Parameters
T
EvalExpression(String)
Evaluate Expressions in ServiceStack's ScriptContext. Can be overridden if you want to customize how different expressions are evaluated.
View Source
object EvalExpression(string expr)
Returns
System.Object
Parameters
Type | Name |
---|---|
System.String | expr |
EvalExpressionCached(String)
Evaluate Expressions in ServiceStack's ScriptContext. Can be overridden if you want to customize how different expressions are evaluated.
View Source
object EvalExpressionCached(string expr)
Returns
System.Object
Parameters
Type | Name |
---|---|
System.String | expr |
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
object EvalScriptValue(IScriptValue scriptValue, IRequest req = null, Dictionary<string, object> args = null)
Returns
System.Object
Parameters
Type | Name |
---|---|
ServiceStack.IScriptValue | scriptValue |
ServiceStack.Web.IRequest | req |
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
Task<object> EvalScriptValueAsync(IScriptValue scriptValue, IRequest req = null, Dictionary<string, object> args = null)
Returns
System.Threading.Tasks.Task<System.Object>
Parameters
Type | Name |
---|---|
ServiceStack.IScriptValue | scriptValue |
ServiceStack.Web.IRequest | req |
System.Collections.Generic.Dictionary<System.String,System.Object> | args |
ConfigurePlugin<T>(Action<T>)
Register a callback to configure a plugin just before it's registered
View Source
void ConfigurePlugin<T>(Action<T> configure)
where T : class, IPlugin
Parameters
Type | Name |
---|---|
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
void PostConfigurePlugin<T>(Action<T> configure)
where T : class, IPlugin
Parameters
Type | Name |
---|---|
System.Action<<T>> | configure |
Type Parameters
T
AfterPluginLoaded<T>(Action<T>)
Register a callback to configure a plugin after AfterPluginsLoaded is run
View Source
void AfterPluginLoaded<T>(Action<T> configure)
where T : class, IPlugin
Parameters
Type | Name |
---|---|
System.Action<<T>> | configure |
Type Parameters
T