Monday, April 30, 2012

Refactoring session check

I have this repetitive code in all the controllers:



        var user = Session["_User"] as User;

if (user== null)
{
return RedirectToAction("Index");
}


How can I refactor this? should i add this to an attribute or make a Session Wrapper?



What would be the best approach?





No comments:

Post a Comment