AuthValidatorAttribute Class

HttpServer.dll

Method marked with this attribute determines if authentication is required.

Namespace:  HttpServer.Controllers
Assembly:  HttpServer (in HttpServer.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#
public class AuthValidatorAttribute : Attribute
Visual Basic (Declaration)
Public Class AuthValidatorAttribute _
	Inherits Attribute
Visual C++
public ref class AuthValidatorAttribute : public Attribute

Remarks

The method should take one parameter (int level), return a bool and be protected/private.

You should throw UnauthorizedException if you are using HTTP authentication.

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; } }

Inheritance Hierarchy

System..::.Object
  System..::.Attribute
    HttpServer.Controllers..::.AuthValidatorAttribute

See Also