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, EventA开发者_开发技巧rgs 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
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()
.
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)
精彩评论