Reputation: 59
What is the best way to check session
?
Right now, my application is checking session in 2 places. One is Master Page_Load and aspx Page_Load and redirecting to session
expire page.
Is it a good way to check same session
two times ?
If not, can we check in Page_Init
?
Upvotes: 1
Views: 156
Reputation: 62260
I normally use BasePage, and place command methods related to Page. Then inherit all pages from it. I cannot say this is the best way.
public partial class _Default : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
public class BasePage : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
if (Session["IsExpired"] == null)
{
// Do something
}
}
}
Upvotes: 1