AppHostHttpListenerBase
Inherit from this class if you want to host your web services inside a Console Application, Windows Service, etc.
Usage of HttpListener allows you to host webservices on the same port (:80) as IIS however it requires admin user privileges.
Assembly: ServiceStack.dll
View Source
public abstract class AppHostHttpListenerBase : HttpListenerBase, IAppHost, IResolver, IFunqlet, IHasContainer, IDisposable
Properties
HandlerPath
View Source
public string HandlerPath { get; set; }
Inherited Properties
BeforeRequest
View Source
public Action<HttpListenerContext> BeforeRequest { get; set; }
Fields
ThreadsPerProcessor
View Source
public static int ThreadsPerProcessor
Methods
CalculatePoolSize()
View Source
public static int CalculatePoolSize()
Returns
System.Int32
ProcessRequestAsync(HttpListenerContext)
View Source
protected override async Task ProcessRequestAsync(HttpListenerContext context)
Returns
System.Threading.Tasks.Task
Parameters
| Type | Name |
|---|---|
System.Net.HttpListenerContext | context |
OnConfigLoad()
View Source
public override void OnConfigLoad()
Inherited Methods
AddUrlReservationToAcl(String)
Reserves the specified URL for non-administrator users and accounts. http://msdn.microsoft.com/en-us/library/windows/desktop/cc307223(v=vs.85).aspx
View Source
public static string AddUrlReservationToAcl(string urlBase)
Returns
System.String: Reserved Url if the process completes successfully
Parameters
| Type | Name |
|---|---|
System.String | urlBase |
CreateHttpListener()
View Source
protected virtual HttpListener CreateHttpListener()
Returns
System.Net.HttpListener
CreateRequest(HttpListenerContext, String)
View Source
public virtual ListenerRequest CreateRequest(HttpListenerContext httpContext, string operationName)
Returns
ServiceStack.Host.HttpListener.ListenerRequest
Parameters
| Type | Name |
|---|---|
System.Net.HttpListenerContext | httpContext |
System.String | operationName |
Dispose(Boolean)
View Source
protected override void Dispose(bool disposing)
Parameters
| Type | Name |
|---|---|
System.Boolean | disposing |
HandleError(Exception, HttpListenerContext)
View Source
public static void HandleError(Exception ex, HttpListenerContext context)
Parameters
| Type | Name |
|---|---|
System.Exception | ex |
System.Net.HttpListenerContext | context |
Listen(Object)
View Source
protected virtual void Listen(object state)
Parameters
| Type | Name |
|---|---|
System.Object | state |
OnAfterInit()
View Source
public override void OnAfterInit()
OnBeginRequest(HttpListenerContext)
View Source
protected virtual void OnBeginRequest(HttpListenerContext context)
Parameters
| Type | Name |
|---|---|
System.Net.HttpListenerContext | context |
ProcessRequestAsync(HttpListenerContext)
Overridable method that can be used to implement a custom handler
View Source
protected abstract Task ProcessRequestAsync(HttpListenerContext context)
Returns
System.Threading.Tasks.Task
Parameters
| Type | Name |
|---|---|
System.Net.HttpListenerContext | context |
ProcessRequestContext(HttpListenerContext)
View Source
public virtual void ProcessRequestContext(HttpListenerContext context)
Parameters
| Type | Name |
|---|---|
System.Net.HttpListenerContext | context |
RemoveUrlReservationFromAcl(String)
View Source
public static void RemoveUrlReservationFromAcl(string urlBase)
Parameters
| Type | Name |
|---|---|
System.String | urlBase |
SetAppDomainData()
View Source
public virtual void SetAppDomainData()
Start(IEnumerable<String>)
View Source
public virtual ServiceStackHost Start(IEnumerable<string> urlBases)
Returns
Parameters
| Type | Name |
|---|---|
System.Collections.Generic.IEnumerable<System.String> | urlBases |
Start(IEnumerable<String>, WaitCallback)
View Source
protected void Start(IEnumerable<string> urlBases, WaitCallback listenCallback)
Parameters
| Type | Name |
|---|---|
System.Collections.Generic.IEnumerable<System.String> | urlBases |
System.Threading.WaitCallback | listenCallback |
Start(String)
View Source
public override ServiceStackHost Start(string urlBase)
Returns
Parameters
| Type | Name |
|---|---|
System.String | urlBase |
Start(String, WaitCallback)
Starts the Web Service
View Source
protected void Start(string urlBase, WaitCallback listenCallback)
Parameters
| Type | Name | Description |
|---|---|---|
System.String | urlBase |
A Uri that acts as the base that the server is listening on. Format should be: http://127.0.0.1:8080/ or http://127.0.0.1:8080/somevirtual/ Note: the trailing slash is required! For more info see the HttpListener.Prefixes property on MSDN.
|
| System.Threading.WaitCallback | listenCallback |
|
Stop()
Shut down the Web Service
View Source
public virtual void Stop()
WriteUnhandledErrorResponse(IRequest, Exception)
View Source
public static void WriteUnhandledErrorResponse(IRequest httpReq, Exception ex)
Parameters
| Type | Name |
|---|---|
| ServiceStack.Web.IRequest | httpReq |
System.Exception | ex |
Implements
- ServiceStack.IAppHost
- ServiceStack.Configuration.IResolver
System.IDisposable