The ASP .Net Suite Module¶
Suite ASP.NET Core Modules are Suite Modules which have also a chance to provide middlewares and other ASP.NET Core symbols.
The ISuiteAspNetModule
extends the ISuiteModule
adding a
ConfigureMiddlewares
method (lifecycle hook).
At ConfigureMiddlewares
, the module may use the IApplicationBuilder
to add
middlewares to the pipeline.
Services may be resolved at this stage by using the app.ApplicationServices
.
Note
There's also an AspNetSuiteModule
"dumb" implementation, which, as mentioned
for the SuiteModule
class, only implements the methods as virtual for being
overridden. There's no difference between using IAspNetSuiteModule
or AspNetSuiteModule
.
If you need to provide middlewares in an specific order other than the provided
by the module dependency order, may be at the beginning or end of the middleware
pipeline, then you'll need to implement IOrderableMiddlewareProvider
and
provide the information about the position and order wanted for your middleware.
Providing middlewares¶
Warning
Do not implement IStartupFilter
by your own to arrange your middleware in the
pipeline, relay always in the IOrderableMiddlewareProvider
implementation to
provide the needed middlewares, otherwise you can get inconsistent application
behavior.
If the AspNetModule.ConfigureMiddlewares
is not sufficient, you are able to
provide a middleware that must be placed at specific point in the
middleware pipeline
, you will need to implement
IOrderableMiddlewareProvider
. By implementing it you tell the Suite Framework
that you want the framework
to place the middleware at certain point in the
ASP.NET Core middleware pipeline
.
There are two properties that must be supplied with values to achieve the desired behavior:
PipelinePosition
: specifies if the middleware provider is meant to be called at the leading or trailing position of themiddleware pipeline
calling chain. There are two possible options:Leading
andTrailing
.Order
: defines the order you want for the middleware in the calling chain, among the other middlewares with the samePipelinePosition
. TheOrder
attribute provides anordinal
precedence for the middlewares.
The order attribute is an int
value, the framework
looks at it to make a
sort operation for the subset of providers with the same PipelinePosition
. The
order operation is performed in descending order either for the Leading
or the
Trailing
positioned middleware providers
. Therefore, higher int
values for
the Leading
positioned middlewares shift the middleware to the head of the
calling chain. For the Trailing
positioned middlewares is the other way
around. The lower is the Order
int
value, the more shifted to the end of the
calling chain the middleware is going to be placed.
We encourage you to use the values provided by PipelineOrderPriority
class, to
make a consistent usage of the Order
property values. This class provide
normal
, high
and higher
suitable values either for the Leading
and
Trailing
properties.
Important
int.Max value and int.Min values are preserved for the case we need to plug a middleware at the very beginning or the very end of the pipeline respectively. The upper and lower int range boundaries must be preserved for this reason and never be used.
Important
If IOrderableMiddlewareProvider
is still insufficient for your needs
please contact Suite dev team
to make an assessment of the situation
before go further.