-
-
Notifications
You must be signed in to change notification settings - Fork 10
Custom controller response
Alexanderius edited this page Jul 3, 2025
·
4 revisions
You can create your custom controller response by deriving from the ControllerResponse
base class and implementing the 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, the
ExecuteAsync
method is called by the framework after controller execution. -
ControllerResponse
has the same properties as theController
base class to access Simplify.Web modules likeDataCollector
orWebContext
; you can use them to perform your actions. - An additional module available to controller responses is
ResponseWriter
, which provides writing to the HTTP response. - The
ExecuteAsync
method should return one of theResponseBehavior
enum types:-
Default
- default result; the framework will process other controllers applicable to the request and generate a page. -
RawOutput
- indicates that subsequent controller execution and page generation should be stopped (for example, if you are providing some custom output to the client); no output data will be sent to the client except your custom writing to the response. -
Redirect
- indicates that the controller response is performing a client redirection; technically the 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