How can I check a variable and redirect to another page before the page loads using ASP.NET?
I\'m aware of the life cycle, and PageInit() sounds like it
you can place this code anywhere in the masterpage to check a variable and redirect to another page before the content page loads.
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (string.IsNullOrEmpty(Convert.ToString(Session["email"])) ||string.IsNullOrEmpty(Convert.ToString(Session["mobile"])))
{
Response.Redirect("Login.aspx");
}
}