Class CqrsHttpApplication
An System.Web.HttpApplication that prepares and configures CQRS with use in IIS or other web server.
Inheritance
Inherited Members
Namespace: Cqrs.Hosts
Assembly: Cqrs.dll
Syntax
public abstract class CqrsHttpApplication : HttpApplication, IHttpAsyncHandler, IHttpHandler, IComponent, IDisposable
Constructors
CqrsHttpApplication()
Instantiate a new instance of a CqrsHttpApplication
Declaration
protected CqrsHttpApplication()
Properties
CommandBus
The ICommandReceiver that will be configured to receive ICommand<TAuthenticationToken>.
Declaration
protected ICommandReceiver CommandBus { get; set; }
Property Value
Type | Description |
---|---|
ICommandReceiver |
EventBus
The IEventReceiver that will be configured to receive IEvent<TAuthenticationToken>.
Declaration
protected IEventReceiver EventBus { get; set; }
Property Value
Type | Description |
---|---|
IEventReceiver |
HandlerTypes
Each System.Type will be traced back to it's assembly, and that assembly will be scanned for other handlers to auto register.
Declaration
protected Type[] HandlerTypes { get; set; }
Property Value
Type | Description |
---|---|
System.Type[] |
Methods
Application_AuthenticateRequest(Object, EventArgs)
Gets executed after Application_BeginRequest(Object, EventArgs). Override this method to extract any authentication token from the request and then call SetAuthenticationToken(TAuthenticationToken).
Declaration
protected virtual void Application_AuthenticateRequest(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.EventArgs | e |
Application_BeginRequest(Object, EventArgs)
Gets executed for each and every request which comes to the application to generate a new CorrelationId and then sets the generated CorrelationId via cdmdotnet.Logging.ICorrelationIdHelper.SetCorrelationId(System.Guid). The generated CorrelationId is also set in the System.Web.HttpResponse.Headers.
Declaration
protected virtual void Application_BeginRequest(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.EventArgs | e |
Application_End(Object, EventArgs)
Gets executed once during the life cycle of the application when it is unloaded. This is normally fired when the application is taken off-line or when the server is stopped.
Declaration
protected virtual void Application_End(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.EventArgs | e |
Application_EndRequest(Object, EventArgs)
Gets executed after Application_BeginRequest(Object, EventArgs) and before the stream starts getting sent to the client.
Declaration
protected virtual void Application_EndRequest(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.EventArgs | e |
Application_Error(Object, EventArgs)
Logs all error via cdmdotnet.Logging.ILogger.LogError(System.String,System.String,System.Exception,System.Collections.Generic.IDictionary{System.String,System.Object},System.Collections.Generic.IDictionary{System.String,System.Object}) unless the execution is System.Security.SecurityException, in which case cdmdotnet.Logging.ILogger.LogWarning(System.String,System.String,System.Exception,System.Collections.Generic.IDictionary{System.String,System.Object},System.Collections.Generic.IDictionary{System.String,System.Object}) is used. Gets executed when any un-handled System.Exception/error occurs anywhere in the application. Any un-handled System.Exception here means exception which are not caught using try catch block. Also if you have custom errors enabled in your application i.e. in web.config file then the configuration in web.config takes precedence and all errors will be directed to the file mentioned in the tag.
Declaration
protected virtual void Application_Error(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.EventArgs | e |
Application_Start(Object, EventArgs)
Calls SetBuses(), RegisterCommandAndEventHandlers(), RegisterServiceParameterResolver(), StartBuses() and finally LogApplicationStarted(). Gets executed once during the life cycle of the application when the first request for any resource in the application is made. A resource can be a page or an image in the application. If the server where the application is hosted is restarted then this is fired once again upon the first request for any resource in the application.
Declaration
protected virtual void Application_Start(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.EventArgs | e |
LogApplicationStarted()
Log that the application has started
Declaration
protected virtual void LogApplicationStarted()
RegisterCommandAndEventHandlers()
Start the BusRegistrar by calling Register(Type[]) passing HandlerTypes
Declaration
protected virtual BusRegistrar RegisterCommandAndEventHandlers()
Returns
Type | Description |
---|---|
BusRegistrar |
RegisterServiceParameterResolver()
Call the static "RegisterDataContracts" method on any IServiceParameterResolver we can find in the System.Reflection.Assembly of any System.Type in HandlerTypes
Declaration
protected virtual void RegisterServiceParameterResolver()
Session_End(Object, EventArgs)
Whenever a user's session in the application expires this gets executed. The session is no longer available or accessible. The session expiration time can be set in web.config file. By default session time out is set to 20 mins.
Declaration
protected virtual void Session_End(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.EventArgs | e |
Session_Start(Object, EventArgs)
Makes a call to retrieve the System.Web.SessionState.HttpSessionState.SessionID. This is done so the session is generated at the beginning of the request. If this isn't called the session (when using WCF) is generated late in the pipeline, which can cause issues when trying to work with WCF. Gets executed after Application_AuthenticateRequest(Object, EventArgs) when a new session for a "user" starts such as a first request or after a session has expired. This event doesn't get triggered if you are not using sessions which can be disabled in the web.config.
Declaration
protected virtual void Session_Start(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.EventArgs | e |
SetBuses()
Set EventBus and CommandBus.
Declaration
protected abstract void SetBuses()
StartBuses()
Starts the command bus and event bus receivers depending on configuration settings
Declaration
protected virtual void StartBuses()