Goal:
Make it easier to validate if the same user or not in relation to DRY.
Problem:
Every time when you go to the next page by using ActionResult
you have to add a
if (Session["UserID"] != null)
in every ActionResult
's content in order to make a validation.
Question:
Is there another approach in order to make it easier and better than today?
My idea is to use this validation on top of the ActionResult
Propose (is it possible to do it?)
[validation]
public ActionResult UserDashBoard()
{
return View();
}
And not like this today:
public ActionResult UserDashBoard()
{
if (Session["UserID"] != null)
{
return View();
} else
{
return RedirectToAction("Login");
}
}
The source that I am using is from this page.
https://www.c-sharpcorner.com/article/simple-login-application-using-Asp-Net-mvc/