我创建了一个包含userID的cookie ..
C#
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
"UserID",
DateTime.Now,
DateTime.MaxValue,
true,
s.EmpID, // userID
FormsAuthentication.FormsCookiePath);
// Encrypt the ticket.
string encTicket = FormsAuthentication.Encrypt(ticket);
// Create the cookie.
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket) {
Expires = ticket.Expiration
});
但问题是,当非管理员用户访问管理页面时,如何显示错误页面,指出权限被拒绝
[Authorize(Roles = "Admin")]
答案 0 :(得分:0)
我将尝试通过我在项目中的表现来解释这一点。