Thursday, November 24, 2011
Wednesday, November 23, 2011
Tuesday, November 22, 2011
Monday, October 3, 2011
Wednesday, June 29, 2011
Check for null session
1 protected void Page_Load(object sender, EventArgs e)
2 {
3 if (Session["UserName"] != null)
4 {
5 //do something
6 }
7 else
8 {
9 Session.Abandon();
10 // sign out the user
11 System.Web.Security.FormsAuthentication.SignOut();
12 // redirect to the login page
13 System.Web.Security.FormsAuthentication.RedirectToLoginPage();
14 }
15 }
How to return back to a specific page in a gridview list?
You can save the PageIndex into Session or ViewState. In the Page_Load event of GridView page you can check it first. If the session is not null, then go to that page with setting PageIndex and rebinding GridView.
The name 'Session' does not exist in the current context
HttpContext.Current.Session["UserID"];