For Example using MVC 5 Razor:
@{
//get user session.
var session = UserManager.Session();
if (session == null)
{
}
}
OR
We can also use the custom action filter to achieve this
functionality. i.e.
For Example :
//
Override onAuthentication filter to achieve this functionality.
//and also get user session to check is null value.
{
session = UserManager.Session();
if ( session == null)
{
RedirectToControllers(Helper.Control.ACCOUNT,
Helper.Action.ACCOUNT_LOGIN);
}
base.OnAuthentication(filterContext);
}