Reputation: 1317
I am storing Boolean value in session if a user is Admin or not after some business logic. This logic implemented in home page itself. Now I need to authorize admin controller based on this session value. Any suggestion or reference link please.
Session["Admin"] = true;
Upvotes: 0
Views: 399
Reputation: 792
You can do something like this in the controller:
Session["Admin"] = true;
if (!(bool)Session["Admin"])
{
//Do the appropriate action here like redirect
return RedirectToAction("NoRights");
}
Upvotes: 1