Check Session Timeot for Whole Application
1. Create a BasePage.cs in App_Code and write the following code
protected void Page_Init(object sender, EventArgs e)
{
if (Context.Session != null)
{
if (Session.IsNewSession)
{
HttpCookie newSessionIdCookie = Request.Cookies["ASP.NET_SessionId"];
if (newSessionIdCookie != null)
{
string newSessionIdCookieValue = newSessionIdCookie.Value;
if (newSessionIdCookieValue != string.Empty)
{
//This means Session was timed Out and New Session was started
Response.Redirect("Home.aspx");
}
}
}
}
}
2. Inherit this basepage on all the aspx pages such as
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using VAS.BLL;
using VAS.DAL;
using VAS.PL;
public partial class _Default: BasePage
{
///body
}
protected void Page_Init(object sender, EventArgs e)
{
if (Context.Session != null)
{
if (Session.IsNewSession)
{
HttpCookie newSessionIdCookie = Request.Cookies["ASP.NET_SessionId"];
if (newSessionIdCookie != null)
{
string newSessionIdCookieValue = newSessionIdCookie.Value;
if (newSessionIdCookieValue != string.Empty)
{
//This means Session was timed Out and New Session was started
Response.Redirect("Home.aspx");
}
}
}
}
}
2. Inherit this basepage on all the aspx pages such as
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using VAS.BLL;
using VAS.DAL;
using VAS.PL;
public partial class _Default: BasePage
{
///body
}
Thanks for sharing Sir..i hope u keep posting!!
ReplyDelete