I tried Googling a few things about custom attributes but I\'m still not sure how to go about it....
I\'m storing a few important details of the user in Session cook
You can create your own version of the Authorize attribute by implementing the IAuthorizationFilter interface. Here's an example:
class MyCustomFilter : FilterAttribute, IAuthorizationFilter
{
public void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext.HttpContext.Session["UserID"] == null)
{
filterContext.Result = new RedirectResult("/");
}
}
}
and a usage example:
[MyCustomFilter]
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}