Debug de pages en extension .asp
liste les variables de session, les cookies, les variables de formulaires (post-get), le temps d’exécustion, les variables personnalisées
Créer un objet debug, nommez le VBScriptDebug.asp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
<SCRIPT RUNAT=Server Language=VBScript> Class clsDebug Dim blnEnabled Dim dteRequestTime Dim dteFinishTime Dim objStorage Public Property Get Enabled() Enabled = blnEnabled End Property Public Property Let Enabled(bNewValue) blnEnabled = bNewValue End Property Private Sub Class_Initialize() dteRequestTime = Now() Set objStorage = Server.CreateObject("Scripting.Dictionary") End Sub Public Sub Print(label, output) If Enabled then objStorage.Add label, output End if End Sub Public Sub [End]() dteFinishTime = Now() If Enabled then PrintSummaryInfo() PrintCollection "VARIABLE STORAGE", objStorage PrintCollection "QUERYSTRING COLLECTION", Request.QueryString() PrintCollection "FORM COLLECTION", Request.Form() PrintCollection "COOKIES COLLECTION", Request.Cookies() PrintCollection "SESSION CONTENTS COLLECTION", Session.Contents() PrintCollection "SERVER VARIABLES COLLECTION", Request.ServerVariables() PrintCollection "APPLICATION CONTENTS COLLECTION", Application.Contents() PrintCollection "APPLICATION STATICOBJECTS COLLECTION", Application.StaticObjects() PrintCollection "SESSION STATICOBJECTS COLLECTION", Session.StaticObjects() End if End Sub Private Sub PrintSummaryInfo() With Response .Write("<hr>") .Write("<b>SUMMARY INFO</b></br>") .Write("Time of Request = " & dteRequestTime) & "<br>" .Write("Time Finished = " & dteFinishTime) & "<br>" .Write("Elapsed Time = " & DateDiff("s", dteRequestTime, dteFinishTime) & " seconds<br>") .Write("Request Type = " & Request.ServerVariables("REQUEST_METHOD") & "<br>") .Write("Status Code = " & Response.Status & "<br>") End With End Sub Private Sub PrintCollection(Byval Name, Byval Collection) Dim varItem Response.Write("<br><b>" & Name & "</b><br>") For Each varItem in Collection Response.Write(varItem & "=" & Collection(varItem) & "<br>") Next End Sub Private Sub Class_Terminate() Set objStorage = Nothing End Sub End Class </SCRIPT> |
Dans le code de votre pages faites appel à l’objet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<%@ Language=VBScript %> <!-- #include file="VBScriptDebug.asp" --> 'votre code ..... 'déclaration de l'objet Dim Debug 'instanciation Set Debug = new clsDebug 'activation Debug.Enabled = true 'debug d'une variiable Debug.Print "du texte", votreVariable 'à mettre à la fin de votre fichier Debug.End Set Debug = nothing |
source