Custom Request Handling
Custom Default Route Handlers
The Platformus.Globalization.Frontend package contains the UseMvcAction class. This class registers the default route (it is done using the features of the underlying ExtCore framework) which is used to handle all the requests in the Platformus-based web application. It is defined here, because this route might include culture segment (depending on the configuration). Also, this project contains the default controller itself.
This controller doesn’t generate any response by itself. It looks for the implementations of the
and executes their
TryHandle() method one by one, until it gets the not-null result. If none of the default route handlers returned a not-null result,
the 404 exception is thrown.
Default route handlers might be considered as a middleware which can process the requests. There is the only one implementation of the
IDefaultRouteHandler interface exists in the Platformus from the box: the
This implementation gets the endpoint resolver service from the DI and gets the endpoint that will handle the request using it. Also,
it performs required security checks.
If you need to handle some requests (and let Platformus to handle other ones as it works by default), just implement the
and return not-null result for some particular requests:
Navigate to http://localhost:5000/en/some-url:
You don’t have any object with such URL, but our default route handler worked and you have the response, not 404 error.
While the previous solution is a bit limited, you can get the full access to the MVC routing system using the features
of the underlying ExtCore framework. You can implement the
and register as many routes as you need: