日期:2014-05-17 浏览次数:20573 次
public class OperatorAuthorizeAttribute : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
var formId = HttpContext.Current.User.Identity as FormsIdentity;
if (formId != null && formId.IsAuthenticated)
{
var rolesTemp = formId.Ticket.UserData.Split('&');
var roles = rolesTemp[0];
if (!Roles.Contains(roles))
{
filterContext.RequestContext.HttpContext.Response.Write("无权访问");
filterContext.RequestContext.HttpContext.Response.End();
}
else
{
FormsAuthentication.RedirectFromLoginPage(formId.Name,false);
}
}
else
{
FormsAuthentication.RedirectToLoginPage();
}
}
}
[OperatorAuthorize(Roles = "3,25,26,27,28,29")]
public ViewResult Index(int? currentPage)
{
int currentIndex = currentPage.HasValue ? currentPage.Value : 1;
int pageSize = CommonAction.GetPageSize();
int total = db.Clients.Count();
&n