Skip to content

Controllers attributes

Alexanderius edited this page Jun 6, 2024 · 3 revisions

Controllers attributes

All controllers attributes can be found in Simplify.Web.Attributes namespace.

Core attributes

  • [Get("route expression")] - indicates that a controller handles only HTTP GET request with specified route expression;
  • [Post("route expression")] - indicates that a controller handles only HTTP POST request with specified route expression;
  • [Delete("route expression")] - indicates that a controller handles only HTTP DELETE request with specified route expression;
  • [Put("route expression")] - indicates that a controller handles only HTTP PUT request with specified route expression.
  • [Patch("route expression")] - indicates that a controller handles only HTTP PATCH request with specified route expression.
  • [Options("route expression")] - indicates that a controller handles only HTTP OPTIONS request with specified route expression.

Route expressions description

Special attributes

  • [Authorize] - indicates that a controller requires user to be authenticated, otherwise client will be redirected to login page;

  • [Authorize("Role1", "Role2")] or [Authorize("Role1, Role2")] - authorize attribute with specifying user roles, only users with one of the specified roles can access controller, otherwise HTTP 403 error will be returned (or controller with Http403 attribute will be called, if it is 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 lower number will be invoked before controllers with 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 user is calling page with specified route expression is not found, then controller with this attribute will be called.

<< Previous page Next page >>

Clone this wiki locally