Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with page format after timeout

Status
Not open for further replies.

OceanDesigner

Programmer
Oct 30, 2003
173
US
I have a problem with the format of my pages. I have not been able to come up with the exact cause. It is definitely related to the use of the back button, and possibly timeout of the server.

I will lay out the basic page format and then describe the problem. The page structure is in the code below. I set up a table with two columns. In the top row, I write a header (from an include file). In the left column of the second row, I put a menu (also from an include file). In the right column of the second row is the main body of the page. The menu displays options based on user roles - so there are several IF statements testing against session variables that house the role.

Basic Page Layout:
Code:
<%
'Authentication code - gets username and level from session variables and redirects to the login page if timed out
'Database transactions
%>
<html>
<body>
<!--#include file="includes/header.htm"-->
<table width="760" border="0" cellpadding="4" align="center">
  <tr> 
    <td width="150" align="left" valign="top"><!--#include file="includes/menu.htm"--></td>
    <td valign="top">
      BODY OF THE PAGE
    </td>
  </tr>
</table>
<!--#include file="includes/footer.htm"-->
</body>
</html>

Example of the menu include file:
Code:
level = Session("role")

<% if level = 10 or level = 2.2 then %> 
<tr><td><a href="AdministrationMenu.asp">Administration Menu</a></td></tr>
<%end if %>

<% if level >= 3 then %> 
<tr><td><a href="WarrantyMenu.asp">Warranty Menu</a></td></tr>
<% end if%>

When the user navigates through the site using the controls (buttons and hyperlinks) built within the pages, the pages behave properly. Periodically, when the browser's Back button is used however, the whole layout gets messed up. First, the menu disappears altogether. Second, the main body displays to the right of the header rather than beneath it. I can't seem to figure out the circumstances that lead up to this behavior. It definitely comes from the use of the back button. I think it also has to do with the server timing out (based on inactivity). I cannot reproduce the behavior consistently. This problem started when we switched the web server from NT to 2003. The problem may be related to the server itsself, or different settings on the new server.

I am fishing a little here because I really don't know what is wrong. Any ideas are really appreciated.

Thanks,Jeff
 
Do you have a defualt value for the menu in your first column? i.e. if the Session("role") does not contain any value what gets displayed for a menu?

If you don't have a default I would suggest - as you said -it could be to do with a session time out. If there's no default then your just going to get nothing in your far left column which will mess up the look of your table.

If you don't want to have a default...I'm not very familiar with session variables so someone else might be able to let you know how to get it to persist for longer. If that's not possible, you could store the user role in a cookie and just use "Request.Cookies" instead. Then it should persist until the user closes thier browser or you explicitly remove it in your code.

Might also be worth investigating using DIV elements and the CSS box model for your layout instead of a table if you have the time. It probably won't make the page work any better but it might be easier to manage.
 
Let me ask a related question. In the past, when the Back button was used, the browser would simply display the previous page exactly how it was rendered when the page was originally evoked. In other words, the page was not re-processed. Now (with the newest vesion of IIS) it seems like the IF statements in my menu include are indeed being re-processed when the Back button is used. Is this a change is IIS, or maybe some type of cache setting? Any recommendations on how I should deal with it? Again, the problem is the IF statements are testing against a session variable, which may be reset if the server has timed out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top