Abhishek  Yadav

Abhishek Yadav

  • 109
  • 17.1k
  • 303.1k

I want to check first the session as this action

Aug 8 2023 5:47 AM

I have an simple MVC app I want to check first the session as this action

public ActionResult Index()
{
    if (Session["UserInfo"] == null)
    {
      return  RedirectToAction("Login", "Users");
    }
    return View();
}

My question is about is there a way to enforce this check to all actions without do it manual for each action?


Answers (2)