Reputation: 8000
I am having a base class which implements some basic authentication for all the pages in the application.
public class BasePage : Page
{
public void Page_PreLoad(object sender, EventArgs e)
{
if (!IsUserValid())
{
Response.Redirect("default.aspx");
}
}
}
public class AuthenticatedUser : BasePage
{
public void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Databind();
}
}
}
How to stop page life cycle for AuthenticatedUser, if the user is invalid?
Thanks, Ashwani
Upvotes: 1
Views: 9211
Reputation: 2108
in Response.Redirect you can set a boolean:
Response.Redirect("Default.aspx", false);
Using method in this mode, the page lifecyce is stopped when method is called.(false is endResponse boolean)
Upvotes: -1
Reputation: 24344
Response.Redirect will absolutely stop the page lifecycle execution. If you did NOT want it to stop, you would add a parameter value of false
after the redirect target.
Maybe I'm not clear on what you're asking, if you wanted to stop without a redirect then use Response.End()
.
Upvotes: 7