Master Page and Sessions

masterpage in , session state , session and master page Toronto, Canada
  • 12 years ago
    hi, I am working on a web application which has a master page. Right now, on every page I am checking for session status(expired or not). And my appication has more than 30 pages. I want to know, should I check the session state on master page so that I don't have to write the code for session check on all the pages? Regards, Royal
  • 12 years ago
    Hi, I do similar things, on my pages. If you are not already using master pages, then i tend to subclass the page object, and then have all my pages inherit my base class. This has several advantages, but the main one, is that if you sub class the page and then provide a session expired property, then you dont need to add a mastertype directive to each page. However, if you are using masterpages and dont need to have access to whether the session has expired and just redirect to a login page, then masterpage is fine. Regards Si
  • 12 years ago
    hi Simon, So what you recommend. Keeping in mind that I have a master page. - Checking session on every content Page. - Checking session only on master page. - Or inherit a base class. Regards Royal
  • 12 years ago
    Hi again, Checking the session on every page is obviously a bad design choice, as if the code is just being repeated without change, then it is pointing that it should be part of a base class. Now if the page has a master page, then it is perfectly feasible to do it in there. The only thing to be wary of, is i think the page page_load fires before the master page page_load event.. If you use a base class, you will need to set the base page load event and then mark it is overridable, and then override it in each page and call mybase.page_load etc. tbh, i use a mixture of the two depending on what the site construction calls for. Si
  • 12 years ago
    Thanks Simon Regards, Royal

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves” - Alan Kay