Controller attributes - SimplifyNet/Simplify.Web GitHub Wiki
Controller attributes
All controller attributes can be found in the Simplify.Web.Attributes namespace.
Core attributes
[Get("route expression")]- indicates that a controller handles only HTTP GET requests with the specified route expression;[Post("route expression")]- indicates that a controller handles only HTTP POST requests with the specified route expression;[Delete("route expression")]- indicates that a controller handles only HTTP DELETE requests with the specified route expression;[Put("route expression")]- indicates that a controller handles only HTTP PUT requests with the specified route expression;[Patch("route expression")]- indicates that a controller handles only HTTP PATCH requests with the specified route expression;[Options("route expression")]- indicates that a controller handles only HTTP OPTIONS requests with the specified route expression.
Special attributes
[Authorize]- indicates that a controller requires the user to be authenticated; otherwise, the client will be redirected to the login page;[Authorize("Role1", "Role2")]or[Authorize("Role1, Role2")]- authorize attribute specifying user roles; only users with one of the specified roles can access the controller, otherwise an HTTP 403 error will be returned (or a controller with the Http403 attribute will be called, if present). Example:[Authorize(nameof(Privilege.DepartmentsManagement), nameof(Privilege.UsersManagement))][Priority(1)]- sets a controller invoke priority; controllers will be sorted and invoked according to their priority number (controllers with a lower number will be invoked before controllers with a higher number). Default controller priority is 0.[Http400]- indicates that a controller handles HTTP 400 errors (not implemented);[Http403]- indicates that a controller handles HTTP 403 errors (user is authenticated but does not have access rights);[Http404]- indicates that a controller handles HTTP 404 errors (page not found). For example, if a user requests a page with a specified route expression that is not found, then the controller with this attribute will be called.