One of my customers is running a website using IIS 5 on Windows 2000 server, all pages are ASP (classic, not .net) and the backend is MSSQL.
They have an online test that customers who have been through a training course must complete in order to become certified. This means 102 questions in random order, presented one at a time. They purchased the test taking ASP scripts from a third party, inserted their header graphic and put it up. So this isn’t code I’m familiar with, and I’m not an ASP expert or even much of an HTML guy anyway.
Most people taking the test are having no problem, but a few are reporting that at some point during the test they suddenly receive the “Page Has Expired” error in stead of the next question. Our testing hasn’t been able to duplicate the error.
The main script (the one that displays the questions one after the other) uses a couple of session variables, a couple of parameters passed after the URL via querystring, and some form data passed via request.form. My understanding is that the “Page Has Expired” means that the form data has expired. But I don’t know why that would be.
Any suggestions? I’ll paste the code from the page below in case anyone wants to sort through it.
<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>Question <%= row %></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language=JavaScript>
<!--
//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com
var message="Function Disabled!";
///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
// -->
</script></head>
<body bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td align="center"><br>
<img src="../home/CertificationImages/546-certification-test.gif" width="546" height="39" />
</td>
</tr>
<tr>
<td width="100%" height="520" valign="top">
<div align="center">
<!--NOTE: Changed width to 100% from 80% to display questions with best word wrap-->
<table width="100%">
<%
dsEmail = Request.QueryString("dsEmail")
dim row
dim tmpArray
row = Request.Form("row")
total = Request.Form("total")
' response.write("row = " & row & "total = " & total & "befor check answer<br>")
if Request.Form("answer") = "next" then
tmpArray = Session("test_answers")
mark_array = session("marks")
tmpArray(4,row) = ""
tmpArray(6,row) = ""
tmpArray(8,row) = ""
tmpArray(10,row) = ""
tmpArray(12,row) = ""
if request.form("radio_answer") = "a1" then
tmpArray(4,row) = true
end if
if request.form("radio_answer") = "a2" then
tmpArray(6,row) = true
end if
if request.form("radio_answer") = "a3" then
tmpArray(8,row) = true
end if
if request.form("radio_answer") = "a4" then
tmpArray(10,row) = true
end if
if request.form("radio_answer") = "a5" then
tmpArray(12,row) = true
end if
if Request.Form("a1") = "yes" then
tmpArray(4,row) = true
end if
if Request.Form("a2") = "yes" then
tmpArray(6,row) = true
end if
if Request.Form("a3") = "yes" then
tmpArray(8,row) = true
end if
if Request.Form("a4") = "yes" then
tmpArray(10,row) = true
end if
if Request.Form("a5") = "yes" then
tmpArray(12,row) = true
end if
if Request.Form("mark") = 1 then
mark_array(row) = 1
end if
if request.form("short_answer") > "" then
tmpArray(20,row) = request.form("short_answer")
end if
Session("test_answers") = tmpArray
session("marks") = mark_array
row = row + 1
row = row + 0
total = total + 0
end if
if row = total then ' um I think im counting 0 to 1 less total not sure
' response.write("redirect to grade total is: " & Request.Form("total") )
'this = "opn_pre_grade.asp?test=" & Request.QueryString("test")
this = "opn_grade.asp?test=" & Request.QueryString("test") & "&" & "dsEmail=" & Request.QueryString("dsEmail")
Response.Redirect(this)
end if
%> <form name="form1" method="post" action="<%= "opn_questions.asp?test=" & Request.QueryString("test") %>&dsEmail=<%=dsEmail%>">
<%
alldata = Session("alldata")
numcols=request.form("numcols")
numrows=request.form("numrows")
' 0 = record number
' 1 = test_name, 2 = question, 3 = answer1, 4 =a1
' 5 answer2 6 a2, 7-8 q3 9-10 q4 11-12 q5
' if you want to show table change to true table nice for trouble shooting
show_full = false
if show_full = true then
FOR rowcounter= 0 TO numrows
response.write "<tr>" & vbcrlf
FOR colcounter=0 to numcols
thisfield=alldata(colcounter,rowcounter)
if isnull(thisfield) then
thisfield=shownull
end if
if trim(thisfield)="" then
thisfield=showblank
end if
response.write "<td valign=top>"
response.write thisfield
response.write "</td>" & vbcrlf
NEXT
response.write "</tr>" & vbcrlf
NEXT
response.write "</table>"
end if
answer_num = 0
if alldata(4,row) = true then
answer_num = answer_num + 1
end if
if alldata(6,row) = true then
answer_num = answer_num + 1
end if
if alldata(8,row) = true then
answer_num = answer_num + 1
end if
if alldata(10,row) = true then
answer_num = answer_num + 1
end if
if alldata(12,row) = true then
answer_num = answer_num + 1
end if
%>
<% If answer_num = 1 then %>
<!-- NOTE: REMOVE MARK CHECKBOX NOT NEEDED
<tr><td><div align="left">Mark
<input type="checkbox" name="mark" value="1">
</div></td></tr>-->
<tr>
<td >
<b><%= (row+1) & ") " & alldata(2,row) %></b></td>
</tr><tr><td><%
if alldata(13,row) > "" then
response.write "<img src='pictures/" & alldata(13,row) & "'>"
end if
if alldata(22,row) > "" then
response.write "<EMBED src='sound/" & alldata(22,row) & "' autostart='true'>"
end if
%></td></tr>
<% if not (alldata(3,row) = "n/a") then %>
<tr>
<td >a)
<input type="radio" name="radio_answer" value="a1">
<%=(alldata(3,row) )%>
<%
if alldata(14,row) > "" then
response.write "<img src='pictures/" & alldata(14,row) & "'>"
end if
if alldata(23,row) > "" then
response.write "<EMBED src='sound/" & alldata(23,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<% if not (alldata(5,row) = "n/a") then %>
<tr>
<td >b)
<input type="radio" name="radio_answer" value="a2">
<%=(alldata(5,row) )%>
<%
if alldata(15,row) > "" then
response.write "<img src='pictures/" & alldata(15,row) & "'>"
end if
if alldata(24,row) > "" then
response.write "<EMBED src='sound/" & alldata(24,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<% if not (alldata(7,row) = "n/a") then %>
<tr>
<td >c)
<input type="radio" name="radio_answer" value="a3">
<%=(alldata(7,row) )%>
<%
if alldata(16,row) > "" then
response.write "<img src='pictures/" & alldata(16,row) & "'>"
end if
if alldata(25,row) > "" then
response.write "<EMBED src='sound/" & alldata(25,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<% if not (alldata(9,row) = "n/a") then %>
<tr>
<td >d)
<input type="radio" name="radio_answer" value="a4">
<%=(alldata(9,row) )%>
<%
if alldata(17,row) > "" then
response.write "<img src='pictures/" & alldata(17,row) & "'>"
end if
if alldata(26,row) > "" then
response.write "<EMBED src='sound/" & alldata(26,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<% if not (alldata(11,row) = "n/a") then %>
<tr>
<td >e)
<input type="radio" name="radio_answer" value="a5">
<%=(alldata(11,row) )%>
<%
if alldata(18,row) > "" then
response.write "<img src='pictures/" & alldata(18,row) & "'>"
end if
if alldata(27,row) > "" then
response.write "<EMBED src='sound/" & alldata(27,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<tr>
<td> <p> </p></td>
</tr>
<%
end if
if answer_num > 1 then
%>
<!-- NOTE: REMOVE MARK CHECKBOX NOT NEEDED
<tr><td><div align="left">Mark
<input type="checkbox" name="mark" value="1">
</div></td></tr>-->
<tr>
<td ><div align="right"> </div>
<%=( (row+1) & ") " & alldata(2,row))%></td>
</tr>
<tr><td><%
if alldata(13,row) > "" then
response.write "<img src='pictures/" & alldata(13,row) & "'>"
end if
if alldata(22,row) > "" then
response.write "<EMBED src='sound/" & alldata(22,row) & "' autostart='true'>"
end if
%></td></tr>
<% if not (alldata(3,row) = "n/a") then %>
<tr>
<td >a)
<input type="checkbox" name="a1" value="yes">
<%=(alldata(3,row))%>
<%
if alldata(14,row) > "" then
response.write "<img src='pictures/" & alldata(14,row) & "'>"
end if
if alldata(23,row) > "" then
response.write "<EMBED src='sound/" & alldata(23,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<% if not (alldata(5,row) = "n/a") then %>
<tr>
<td >b)
<input type="checkbox" name="a2" value="yes">
<%=(alldata(5,row))%>
<%
if alldata(15,row) > "" then
response.write "<img src='pictures/" & alldata(15,row) & "'>"
end if
if alldata(24,row) > "" then
response.write "<EMBED src='sound/" & alldata(24,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<% if not (alldata(7,row) = "n/a") then %>
<tr>
<td >c)
<input type="checkbox" name="a3" value="yes">
<%=(alldata(7,row))%>
<%
if alldata(16,row) > "" then
response.write "<img src='pictures/" & alldata(16,row) & "'>"
end if
if alldata(25,row) > "" then
response.write "<EMBED src='sound/" & alldata(25,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<% if not (alldata(9,row) = "n/a") then %>
<tr>
<td >d)
<input type="checkbox" name="a4" value="yes">
<%=(alldata(9,row))%>
<%
if alldata(17,row) > "" then
response.write "<img src='pictures/" & alldata(17,row) & "'>"
end if
if alldata(26,row) > "" then
response.write "<EMBED src='sound/" & alldata(26,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<% if not (alldata(11,row) = "n/a") then %>
<tr>
<td >e)
<input type="checkbox" name="a5" value="yes">
<%=(alldata(11,row))%>
<%
if alldata(18,row) > "" then
response.write "<img src='pictures/" & alldata(18,row) & "'>"
end if
if alldata(27,row) > "" then
response.write "<EMBED src='sound/" & alldata(27,row) & "'>"
end if
%></td>
</tr>
<% end if %>
<tr>
<td> <p> </p></td>
</tr> <%
end if
if answer_num = 0 then
%>
<!-- NOTE: REMOVE MARK CHECKBOX NOT NEEDED
<tr><td><div align="left">Mark
<input type="checkbox" name="mark" value="1">
</div></td></tr>-->
<tr>
<td >
<%= (row+1) & ") " & alldata(2,row) %></td>
</tr><tr><td><%
if alldata(13,row) > "" then
response.write "<img src='pictures/" & alldata(13,row) & "'>"
end if
if alldata(22,row) > "" then
response.write "<EMBED src='sound/" & alldata(22,row) & "' autostart='true'>"
end if
%></td></tr>
<tr>
<td>Short Answer =
<input type="text" name="short_answer"></td>
</tr>
<%
end if %>
<% 'NOTE: ADD THIS FOR FINAL QUESTION BUTTON
if (row) = (total - 2) then %>
<tr>
<td><input type="submit" name="Submit3" value="LAST Question"><br><br><b><font color="blue">You are Almost Done!</font></b></td>
</tr>
<input type="hidden" name="answer" value="next">
<input type="hidden" name="row" value="<%= row %>">
<input type="hidden" name="total" value="<%= Request.Form("total") %>" >
<input type="hidden" name="numrows" value="<%= numrows %>">
<input type="hidden" name="numcols" value="<%= numcols %>">
</form>
<% elseif (row) = (total - 1) then %>
<tr>
<td><input type="submit" name="Submit2" value="Grade Test"><br><br><b><font color="blue">Answer this Question and Test is Completed.<br>Then, Click Grade Test Button for Results.</font></b></td>
</tr>
<input type="hidden" name="answer" value="next">
<input type="hidden" name="row" value="<%= row %>">
<input type="hidden" name="total" value="<%= Request.Form("total") %>" >
<input type="hidden" name="numrows" value="<%= numrows %>">
<input type="hidden" name="numcols" value="<%= numcols %>">
</form>
<% else %>
<tr>
<td><input type="submit" name="Submit" value="Next Question"></td>
</tr>
<input type="hidden" name="answer" value="next">
<input type="hidden" name="row" value="<%= row %>">
<input type="hidden" name="total" value="<%= Request.Form("total") %>" >
<input type="hidden" name="numrows" value="<%= numrows %>">
<input type="hidden" name="numcols" value="<%= numcols %>">
</form>
<% end if %>
</table>
</div>
</td></tr></table>
</body>
</html>
<!--#include file="test_close.asp" -->