Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

sql server 2005 - Error Handling in Classic Asp without timeout error

In classic asp page, i need to catch the error description and insert into a table in the database. when i use 'on error resume next', i am getting a timeout error as follows:

The maximum amount of time for a script to execute was exceeded. You can change this limit by specifying a new value for the property Server.ScriptTimeout or by changing the value in the IIS administration tools

Please help me to catch the exception and insert into database.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I believe your question is "How do I trap the Script Timeout error and record it in the database". Then the answer is you can't do it with On error resume next.

The problem is that ASP has determined your script has run for too long. In order for your code to trap and record the error your code needs to continue but that is exactly what ASP has determined shouldn't happen since its time is up.

Also in general unless you can continue to do something sensible (and that does not include logging) in your script there is no point trying to use On Error Resume Next to trap the error.

Instead create a new ASP script that should run whenever you get a script error (this will include a Script timeout error). In IIS manager open your applications property dialog and select the Custom Errors tab. Edit the handler for the 500;100 HTTP error and change it to URL and the path of this ASP script.

Now you can place your error logging code in this ASP script. You can access the error thrown by the failing ASP page by accessing the Server.GetLastError method. You can also configure this page to send something friendly to the user.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...