-
-
Notifications
You must be signed in to change notification settings - Fork 10
Custom controller response
Alexanderius edited this page Jun 7, 2024
·
4 revisions
You can create your custom controller response by deriving from ControllerResponse base class and implementing ExecuteAsync method.
public class MyControllerResponse : ControllerResponse
{
public override async Task<ResponseBehavior> ExecuteAsync()
{
// Do your response action
/// await ....
return ResponseBehavior.Default;
}
}public class MyControllerResponse : ControllerResponse
{
public override Task<ResponseBehavior> ExecuteAsync()
{
// Do your response action
return Task.FromResult(ResponseBehavior.Default);
}
}- When a controller returns your controller response then the
ExecuteAsyncmethod called by framework after controller execution; -
ControllerResponsehas the same properties likeControllerbase class to access Simplify.Web modules likeDataCollectororWebContext, you can use them to do your actions; - Additional module available to controller response is
ResponseWriter, this module provides writing to the HTTP response; -
ExecuteAsyncmethod should return one of theResponseBehaviorenum types:-
Default- default result, framework will process other controllers applicable to the request and generate a page; -
RawOutput- indicates that subsequent controllers execution and page generation should be stopped (for example, if you are providing some custom output to client), no output data will be sent to the client except your custom writing to the response; -
Redirect- indicates that controller response doing some client redirection, technically same asRawOutput.
-
- Getting Started
- Main Simplify.Web principles
- Simplify.Web controllers
- Simplify.Web views
- Simplify.Web templates
- Simplify.Web configuration
- Templates variables
- Static content
- Template factory
- Data collector
- String table
- File reader
- Web context
- Environment
- Dynamic environment
- Language manager
- Redirector
- HTML