Session Session_OnEnd is more difficult to debug because:
First, there is no error message hint (This is no wonder, there is no place to hint, do not know where to put the error message to where to go).
Second, in most cases, also can not use Session.Abandon to manually release sesion for debugging-you released all the session, then you do not use the session in the Session_OnEnd object? So, I had to wait for the session to timeout. Fortunately, the session timeout domain can be set itself, debugging set a small point, such as 2 minutes or 1 minutes.
If you only have one computer, it will be more difficult to debug, why not I said it.
Let me tell you a little bit about my experience in debugging Session_OnEnd:
First, do not doubt your session_onend did not carry out (in fact, I also suspected at the beginning, because always believe that their own session_onedn events are not wrong), often hear some people complain: "How my session_onend did not carry out, session_ OnStart is good ", of course, Session_OnStart easy to see.
If you don't believe it, you put a tag on the first line of the Session_OnEnd.
Sub Session_OnEnd
Application ("Flag1") = "Session_OnEnd already executed"
............ The back is your Session_OnEnd content.
End Sub
Then, after the session timeout, see the value of application ("Flag1") with Apptest.asp?key=flag1 (followed by apptest.asp), and you can certainly see "Session_OnEnd has been executed."
So, once your session_onend is not up to your goal, you should review your Session_OnEnd events to see if they are written--just like ASP files, Session_OnEnd to stop executing immediately if they encounter an error ...
Second, write Session_OnEnd event must be careful, to ensure that every word is not wrong, to ensure that there is no grammar, no logical errors. This can only be your eyes and thinking can help you.
Here are the methods I used to debug the Session_OnEnd event in the chat room for university reference:
I set a few tags in the following program: FLAG1,FLAG2,FLAG3,FLAG4,FLAG5
<script language= "VBScript" runat= "Server" >
Sub Session_OnEnd
Ip=session ("Userip")
Application ("Flag1") =ip--tag Flag1
Chatdata=application ("Chatdata")
Onliuser=application ("Onliuser")
Kicklist=application ("Kicklist")
Uleave=false
For I=0 to 50
If Chatdata (i,1) =ip Then
Kicklist=replace (Kicklist, ", ' #" &chatdata (i,0) & "'", "")
Onliuser=replace (Onliuser, "," "&chatdata (i,0) &" "" ")
Chatdata (i,0) = ""
Chatdata (i,1) = ""
Chatdata (i,2) =0
Chatdata (i,3) = ""
Chatdata (i,4) =0
Chatdata (i,5) = ""
Uleave=true
Application ("Flag2") = "Find a chat with IP"--Mark Flag2
End If
Next
Kicklist=replace (Kicklist, ", '" &ip& "", "")
Application ("flag3") = "Kicklist value is:" &kicklist--tag Flag3
If Uleave Then
For I=0 to 50
Chatdata (i,4) = (chatdata (i,4) mod 4) # +4
Next
Application ("Flag4") = "Updated list of notifications executed"--Mark Flag4
End If
Application ("flag5") = "4th Mark"-Mark Flag5
Application.Lock
Application ("Kicklist") =kicklist
Application ("Onliuser") =onliuser
Application ("Chatdata") =chatdata
Application.UnLock
Application ("Flag6") = "Application variable update executed"--Mark Flag6
End Sub
</script>
Then open the window, log in to chat room, close the browser (do not exit normally), and so on session timeout. Session timeout (preferably on another computer), with Apptest.asp?key=flag6......apptest.asp?key=flag5......apptest.asp?key=flag4 ... Look at the values of each application to see where my program actually executes.
Unless you see the last Mark Flag6 has a value, otherwise prove that your program has a syntax error!!
This will find the program in that part of the error, and then analyze the wrong part, repeat the above steps, until your session_onend to meet your requirements.
For example, the value of your flag3, but Flag2 does not have a value, it means that the flag2 and flag3 between the program section has syntax errors ...
Attached: Debug Program apptest.asp
Program Name: apptest.asp
Program function: View Application variable Value
Call method: apptest.asp?key= variable name &keyd= dimension, key is the application variable name to view, Keyd the array dimension that the application variable holds. When Keyd is omitted, it means that the application variable is not an array.
<center>application Variable Viewer </center>
<%
Key=request ("key")
Keyd=request ("Keyd")
If keyd= "" Then
Response.Write Application (Key)
Response.End
End If
Username=application (Key)
Select Case Keyd
Case "2"
For I=0 to 50
For J=0 to 5
Response.Write Username (i,j) &chr &CHR (10)
Next
Next
Case "1"