I have a application where I am trying to redirect on session time out so therefore in my master page I am checking if session variable is null for the redirection but the problem is that I have other pages(derived) from masterpage and on Page_Load of derived pages i am referencing some session variables there also and I've observed that PAGE_LOAD event of derived pages(content) fires first and master page PAGE_LOAD fires later so the error is popping "Object reference not set".
By the way I am writing following code on LOGIN_BUTTON_PRESSED EVENT.
FormsAuthenticationTicket ticket - new FormsAuthenticationTicket(1, userName, DateTime.Now, DataTime.Now.AddMinutes(20), true, myRoles, FormsAuthentication.FormsCookiePath);
Session["uid"] = userName.Text;
Session["ufullname"] = ufname;
string hashCookies = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies);
Response.Cookies.Add(cookie);
Response.Redirect("~/Main.aspx");
Please suggest a solution to overcome this problem with example.