Skip to content

Instantly share code, notes, and snippets.

@winsonet
Created November 9, 2019 04:03
Show Gist options
  • Save winsonet/417479020d3d74edea3babb132753f66 to your computer and use it in GitHub Desktop.
Save winsonet/417479020d3d74edea3babb132753f66 to your computer and use it in GitHub Desktop.
[Acl("Account", AllowActions: "Index,View")]
public class CirculationController : BaseController
{
public CirculationController()
{
}
public ActionResult Index()
{
//do something...
}
public ActionResult AjaxHandler()
{
//do something...
}
public ActionResult View()
{
//do something...
}
public ActionResult Others()
{
//do something...
}
}
public class AclAttribute : AuthorizeAttribute
{
string _notAllowRoles;
string _allowActions;
/// <summary>
/// Set the ACL attribute for access right
/// </summary>
/// <param name="NotAllowRoles">Not allow roles, split with comma</param>
/// <param name="AllowActions">Set the actions allow for the restrict roles</param>
public AclAttribute(string NotAllowRoles, string AllowActions = null)
{
_notAllowRoles = NotAllowRoles;
_allowActions = AllowActions;
}
public AclAttribute() : base()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment