开发者

ASP Classic Script Timeout Debug on IIS6?

I have an ASP Classic app th开发者_如何学运维at was moved from a Windows 2000 server to a Windows 2003 R2 server for various reasons. Most of the classic ASP works fine. The problem is, one page will always return a "Script Timeout" to the log and a 500 error to the user. I tried turning CustomErrors off, but still don't know what line of code is causing the error. Can anyone provide some insight on how to find the line that is timing out?


Have the checked the IIS logs, and have you checked they are logging as much as they can? By default, they are in Windows or WinNT \system32\logs.... IIS manager will tell you exactly.

You could also add some logging to a text file, or print to screen, to see if that helps you diagnose the issue.


If the logs are not telling you anything, then you need to make sure IIS accesses the page, I would add

Response.Write ("something")
Response.End

at the very top of the page, if it prints somethin, then you know the problem is in the page and you need to analyse the vb-script on it to find the code that halts. Response.End is quite useful for that purpose.


Sounds like you're into the debugging phase.

In the offending page, start removing code until you get something to work. The last thing removed is likely the problem.


in iis set the value "send errors to browser" to true. then the complete error message incl. line numbers is sent to the client. (in IE you have to set "show short http errors to false")

alternativley set "serverside debugging" in iis to true and in your script (assuming you are using vbscirpt) you could use the "stop" keyword of vbscript.

then a prompt for debugging will pop up


Try using Option Explicit to get a clearer error - this may initially cause more errors since you need to properly declare every variable, but it does give more verbose error messages.

Another thing I find is that script timeouts are usually caused by the script entering an infinite loop - so check all the loops to make sure they exit properly.


I use the following code, for finding the error in the ASP page.

<%
dim objASPError
'Grab the error stuff and quickly release
 Set objASPError = Server.GetLastError
on error resume next
strForm     = Request.Form
strQuery    = Request.QueryString
TheMessage= "<table border=0 width=90% cellpadding=1 cellspacing=0>"_
& "<tr><td>"_
& "<table width=100% cellpadding=5 cellspacing=0 border=0>"_
& "<tr><td colspan=2>Hi: Admin. Fatal Error occured as follows<br></td></tr>"_
& "<tr><td>"_
& "<li><b>Error occured at: " & Now() & " </b></ul>"_
& "<li><b>Referred from:"&request.ServerVariables("HTTP_REFERER")&" </b></ul>"_
& "<li><font color=#000000 face=verdana,arial,helvetica size=1><b>Url: " & request.ServerVariables("URL") & " </b></ul>"_
& "<li><b>Category: " & objASPError.Category & " </b></ul>"_
& "<li><b>Filename: " & objASPError.File & " </b></ul>"_
& "<li><b>ASP Code: " & objASPError.ASPCode & " </b></ul>"_
& "<li><b>Number: " & objASPError.Number & " </b></ul>"_
& "<li><b>Source: " &objASPError.Source & " </b></ul>"_
& "<li><b>LineNumber: " &objASPError.Line & " </b></ul>"_
& "<li><b>Column: " &objASPError.Column & " </b></ul>"_
& "<li><b>Description: " & objASPError.Description & " </b></ul>"_
& "<li><b>ASP Description: " & objASPError.ASPDescription & " </b></ul>"_
& "<li><b>All HTTP: " & Request.ServerVariables("ALL_HTTP")&" </b></ul>"_
& "<li><b>POST Fields: " & strForm &" </b></ul>"_
& "<li><b>GET Fields: " & strQuery &" </b></ul>"_
& "</td></tr></table>"
Set objASPError = Nothing
Response.Write TheMessage
%>

In the above code, instead of displaying the error message, you could also send it to your email address or store it in your database as error log.

Or you could use this configuration in your web.config file, if you are using IIS 7+

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Custom">
                <error statusCode="500" subStatusCode="100" path="/500-100.asp" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

Steps to follow:

  1. Create the custom error ASP file. Name it 500-100.asp

  2. Configure your IIS custom error pages to call this page. You should set it for 500.100 errors.

Check this link to learn, how to set Custom Error Page in IIS 7+

Check this link to learn, how to set Custom Error Page in IIS 6

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜