lundi 9 mai 2016

Check session object and return accordingly

I have following code in my controller actions. I have more than 15 controllers and more than 40 actions through out the application. Instead of checking session for each and every action, how nicely and bett

//Check if USER SESSION object is available
            if (Session["user"] != null)
            {
                //code
                return View();
            }
            else
            {
                return RedirectToAction("logout", "Home", new { area = "Common", value = "SessionTimeOut" });
            }

I just don't want to repeat the if statement for all 40 actions. Any better way of doing this?

Thanks,

Aucun commentaire:

Enregistrer un commentaire