TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Custom Role Authorization, MVC
Aravindhan Dhandapani
Jul 27
2015
Code
900
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
using
System.Web.Mvc;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited =
true
, AllowMultipe =
true
)]
public
class
ComponentViewer : AuthorizeAttribute
{
private
static
IEnumerable<
string
> RoleList =
new
string
[]{
"Role1"
,
"Role2"
,
"Role3"
};
private
static
string
RoleValue = String.Join(ROLE_DELIMITER,RoleList);
private
const
string
ROLE_DELIMITER =
","
;
public
ComponentViewer()
{
Roles = RoleList;
}
public
static
IEnumerable<
string
> ComponentViewerRoles
{
get
{
return
RoleList;
}
}
}
Custom Role Authorization
Authorization