The ASP Server.GetLastError() Method is used to return an ASP Error Object which defines the error condition that occurs. Generally, A website uses a Default file \iishelp\common\500-100.asp to encounter an error in the ASP file. Or we can also create our own file. This method is available only before the .asp file has sent any content to the client.
Note: A 500;100 custom error will be generated if IIS encounters an error while processing either an ASP file or the application’s Global.asa file.
Parameter Value: This method does not contain any parameter value.
Return Values: This method does not return any value.
The below example demonstrates the different types of errors. Basically, there are three types of errors:
- Preprocessing errors: In the Below example an error will occur when IIS tries to include the file because the include statement is missing the file parameter:
<!--#include f="header.inc" --> <% response.write("sometext") %>
- Script compiling errors: Below code demonstrates an error will occur when compiling the script because the “next” keyword is missing:
<% dim i for i=1 to 10 ........ nxt %>
- Run-time errors: Below code demonstrates an error will occur because the script attempts to divide by 0:
<% dim i,tot,j i=0 tot=0 j=0 for i=1 to 10 tot=tot+1 next tot=tot/j %>
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.