110,537
社区成员
发帖
与我相关
我的任务
分享
[Authorize(Roles ="Admin")]
public ActionResult Index()
{
ListPruduct = base.Context.Product.Include("FK_Table_Category").ToList();
return View(ListPruduct);
}
public ActionResult ProductAdd(int id = 0)
{
if (id > 0)
{
var model = ListPruduct.Where(p => p.PK_ID == id).FirstOrDefault();
return View(model);
}
return View(new Product());
}
[AllowAnonymous]
public ActionResult Login(SystemUser user)
{
var login = base.Context.SystemUser.Where(a => a.Password == user.Password && a.Accounts == user.Accounts).FirstOrDefault();
if (login != null)
{
System.Web.Security.FormsAuthentication.SetAuthCookie(login.Accounts, false,"UserName"); //登录这里要如何设置角色权限呢?
return Redirect("Index");
}
return View();
}