ASP Error Trapping

liunx

Guest
I have an asp page that calls a function to process a piece of data on a form submission (the form submits to itself if that matters). If the wrong type of data is entered an error occurs. I would like to trap that error. I know how to do it in vb with an error handler but not so sure how to do it in asp. Any help?

Thanks in advance!ASP VBScript error handling is, well, "limited" :)

On Error Resume Next

then test the err object after every code line that might cause an error.Originally posted by Doug G
ASP VBScript error handling is, well, "limited" :)

On Error Resume Next

then test the err object after every code line that might cause an error.

true, but ISS 6.0 comes with an ASPError object that gives all sort of information about the error.....more than I've seen with others.

It's not really that much worse than a Try....Catch in JAVA.....just that there are certain things in VB where if it keeps going after an error because of the resume next, then you can have more problems - mainly with recordsets where things like JAVA dont have that sorta problem much.IIS 6 has no more error trapping than that of IIS 5. In .net you can also use try catch statements in IIS 5 and 6.

Never use the "Resume Next" statement on an ASP page. If the error occurs let it fail.

But to help you debug possible issues in the page. you can set up an ASP page that sends an email with all the server,querystring,form,Cookies,Application,Session variables. This will help you find the error so you can fix it

Dim errObject
Set errObject = Server.GetLastError()

<!-- m --><a class="postlink" href="http://devguru.com/Technologies/asp/quickref/asperror.html">http://devguru.com/Technologies/asp/qui ... error.html</a><!-- m -->

details about how to use its properties..

Note that you will have to Response.Clear at the top of the page, and also set Response.Status = 500 so that the logging correctly records the error and that the contents of the last page are not ouput also with the new page.


After creating this page, in IIS website Properties there is a "Custom Errors" tab that you can use. find 500 message and edit the properties to URL in the drop down and then enter the path to the file. Relative to the site. so if its in the root of the application you need to place /Page.asp so that it will always go to the root even if in sub directory.Dim errObject
Set errObject = Server.GetLastError()


That's the thing I was thinking was added on 6.0, but it must have been 5.0 (along with the ASPError Object)

At any rate, we're stuck on 4.0 here at work because one other group in our company have these consultants come in and analyze their coding techniques and practices and that company has some stupid software that hasn't been tested (or we haven't upgraded) for anything past whatever came in the NT Option Pack.

Speaking of which, if you have any documentation on certain security holes and all that jazz that would be formal and what-not and I could plop on our Manager's desk to say "we REALLY need to upgrade because of [blah]" - that'd be awesome.

Additional Coding features don't seem to be enough of a swaying points with the powers that be to upgrade our server.First on the list is that there are no more patches coming out for NT 4, no upgrades for IE etc will work either ....

RPC bugs that are in 2000 that were patched are still there on NT 4.

NETBIOS spoofing is easier on NT 4.

No Support for Active Directory on NT 4, which means very weak passwords and even worse reversible.

Load Balancing with 2000/2k3 will ensure availablity of your sites.

Routing and Remote Access flaw which will allow compromised computers with admin access on your network.

Multiple buffer over runs in IIS 4.

Better control over group policies, which could limit sites users can visit, programs that can be used by certain users/groups.

IIS 6, SSL now kernel level instead of Filter.

IIS 6, now prohibits long url's from even touching your server, not to mention 2k3 SP1 will introduce the same stuff XP SP1 did, with non-executable stack, no more buffer overruns.
 
Back
Top