AuthRequiredAttribute Constructor (Int32)
From HttpServer.dll
| C# Webserver |
| AuthRequiredAttribute Constructor (Int32) |
| AuthRequiredAttribute Class Example See Also Send Feedback |
Initializes a new instance of the AuthRequiredAttribute class
Namespace:
HttpServer.Controllers
Assembly:
HttpServer (in HttpServer.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
| C# |
|---|
public AuthRequiredAttribute( int level ) |
| Visual Basic (Declaration) |
|---|
Public Sub New ( _ level As Integer _ ) |
| Visual C++ |
|---|
public: AuthRequiredAttribute( int level ) |
Parameters
- level
- Type: System..::.Int32
Level is a value defined by you. It should be used to determine the users that can access the method tagged with the AuthRequired attribute.
Examples
public enum UserLevel
{
Guest,
User,
Admin,
SuperAdmin
}
public class UserController : RequestController
{
[AuthRequired(UserLevel.User)]
public string View()
{
return "Can also be viewed by users";
}
[AuthValidatorAttribute]
public bool ValidateUser(int level)
{
(User)user = Session["user"];
return user != null && user.Status >= level;
}
}