你可以得到不錯的,但不能從ASP偉大的信息,當你有一個錯誤。
但是你可以在ASP土地define a custom 500 error code page,當你的程序崩潰時可以給你更多的信息。以下是一些示例代碼,它們會針對您的錯誤構建相當體面的錯誤消息。
Set objASPError = Server.GetLastError
Dim strProblem
strProblem = "ASPCode: " & Server.HTMLEncode(objASPError.ASPCode) & vbCrLf
strProblem = strProblem & "Number: 0x" & Hex(objASPError.Number) & vbCrLf
strProblem = strProblem & "Source: [" & Server.HTMLEncode(objASPError.Source) & "]" & vbCrLf
strProblem = strProblem & "Category: " & Server.HTMLEncode(objASPError.Category) & vbCrLf
strProblem = strProblem & "File: " & Server.HTMLEncode(objASPError.File) & vbCrLf
strProblem = strProblem & "Line: " & CStr(objASPError.Line) & vbCrLf
strProblem = strProblem & "Column: " & CStr(objASPError.Column) & vbCrLf
strProblem = strProblem & "Description: " & Server.HTMLEncode(objASPError.Description) & vbCrLf
strProblem = strProblem & "ASP Description: " & Server.HTMLEncode(objASPError.ASPDescription) & vbCrLf
strProblem = strProblem & "Server Variables: " & vbCrLf & Server.HTMLEncode(Request.ServerVariables("ALL_HTTP")) & vbCrLf
strProblem = strProblem & "QueryString: " & Server.HTMLEncode(Request.QueryString) & vbCrLf
strProblem = strProblem & "URL: " & Server.HTMLEncode(Request.ServerVariables("URL")) & vbCrLf
strProblem = strProblem & "Content Type: " & Server.HTMLEncode(Request.ServerVariables("CONTENT_TYPE")) & vbCrLf
strProblem = strProblem & "Content Length: " & Server.HTMLEncode(Request.ServerVariables("CONTENT_LENGTH")) & vbCrLf
strProblem = strProblem & "Local Addr: " & Server.HTMLEncode(Request.ServerVariables("LOCAL_ADDR")) & vbCrLf
strProblem = strProblem & "Remote Addr: " & Server.HTMLEncode(Request.ServerVariables("LOCAL_ADDR")) & vbCrLf
strProblem = strProblem & "Time: " & Now & vbCrLf
編輯在IIS7 GetLastError函數似乎沒有任何可用的信息。
您可以通過創建500.100來解決該問題,並在腳本中指出該問題。
YMMV,查看這些URL以獲取更多信息http://forums.iis.net/t/1150502.aspx和http://www.tacticaltechnique.com/web-development/classic-asp-getlasterror-in-iis7/
Eduardo Molteni的編輯是一個很好的解決方法! –