Server.GetLastError

This is a discussion on "Server.GetLastError" within the Classic ASP section. This forum, and the thread "Server.GetLastError are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Closed Thread
 
LinkBack Thread Tools
  #1  
Old Mar 2nd, 2004, 15:07
Reputable Member
Join Date: Sep 2003
Location: USA
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Server.GetLastError

I want to create my own error pages. My users freak out when they get a real error page.

So I went and did some research and stumbled upon Server.GetLastError. I thought, "Well this doesn't look hard". Ha.

What I want is to have an email with all the pertinate information sent to me so that I see the error details (some users couldn't figure out how to get that to me so I want to get the info myself). Then I want it to print out a generic error thing.

This is what I encounter:
My email script doesn't run. I've even changed the page and it doesn't seem to notice.

Of course, I don't understand what's going on on the IIS side, so maybe it's something weird there.

Thanks
jakyra
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Mar 2nd, 2004, 16:05
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Can you be more specific than: "My email script doesn't run"

Get any errors? Does it just hang? What version of IIS are you hosting this on? Server.GetLastError wont work on IIS4.

Please provide more details, and maybe post some code?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Mar 2nd, 2004, 16:39
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,186
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
You did tie this in via the custom error pages tab in the IIS Manager, yeah?

Also, did you tie it to the 500.100 error? make sure this is where it is applied to.

This code is taken directly from the Microsoft Knowledge Base:-
Code: Select all
<%@Language="VBSCRIPT"%>
<%
  Option Explicit
  On Error Resume Next
  Response.Clear
  Dim objError
  Set objError = Server.GetLastError()
%>
<html>
<head>
<title>ASP 500 Error</title>
<style>
BODY  { FONT-FAMILY: Arial; FONT-SIZE: 10pt;
        BACKGROUND: #ffffff; COLOR: #000000;
        MARGIN: 15px; }
H2    { FONT-SIZE: 16pt; COLOR: #ff0000; }
TABLE { BACKGROUND: #000000; PADDING: 5px; }
TH    { BACKGROUND: #0000ff; COLOR: #ffffff; }
TR    { BACKGROUND: #cccccc; COLOR: #000000; }
</style>
</head>
<body>

<h2 align="center">ASP 500 Error</h2>

<p align="center">An error occurred processing the page you requested.

Please see the details below for more information.</p>

<div align="center"><center>

<table>
<% If Len(CStr(objError.ASPCode)) > 0 Then %>
  <tr>
    <th nowrap align="left" valign="top">IIS Error Number</th>
    <td align="left" valign="top"><%=objError.ASPCode%></td>
  </tr>
<% End If %>
<% If Len(CStr(objError.Number)) > 0 Then %>
  <tr>
    <th nowrap align="left" valign="top">COM Error Number</th>
    <td align="left" valign="top"><%=objError.Number%>
    <%=" (0x" & Hex(objError.Number) & ")"%></td>
  </tr>
<% End If %>
<% If Len(CStr(objError.Source)) > 0 Then %>
  <tr>
    <th nowrap align="left" valign="top">Error Source</th>
    <td align="left" valign="top"><%=objError.Source%></td>
  </tr>
<% End If %>
<% If Len(CStr(objError.File)) > 0 Then %>
  <tr>
    <th nowrap align="left" valign="top">File Name</th>
    <td align="left" valign="top"><%=objError.File%></td>
  </tr>
<% End If %>
<% If Len(CStr(objError.Line)) > 0 Then %>
  <tr>
    <th nowrap align="left" valign="top">Line Number</th>
    <td align="left" valign="top"><%=objError.Line%></td>
  </tr>
<% End If %>
<% If Len(CStr(objError.Description)) > 0 Then %>
  <tr>
    <th nowrap align="left" valign="top">Brief Description</th>
    <td align="left" valign="top"><%=objError.Description%></td>
  </tr>
<% End If %>
<% If Len(CStr(objError.ASPDescription)) > 0 Then %>
  <tr>
    <th nowrap align="left" valign="top">Full Description</th>
    <td align="left" valign="top"><%=objError.ASPDescription%></td>
  </tr>
<% End If %>
</table>

</center></div>

</body>
</html>
For more info, see this article:- http://support.microsoft.com/default...b;EN-US;224070
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Mar 2nd, 2004, 18:15
Reputable Member
Join Date: Sep 2003
Location: USA
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
The original code looks like this:
Code: Select all
<html>
<head>
<%
	dim myDate
	dim PageTitle
	 myDate = "February 27, 2004"
	 PageTitle = "Error"
%>




<% ErrorHandler %>

</head>

<body bgcolor="#ffffe0" text="#660000">




<h2>Error Report</h2>
The action you requested has performed an error. The site administrator has been notified and will contact you when the error has been rectified or if she has any questions.


We appologize for the inconvience. 





</body>
</html>
Where ErrorHandler.asp is:
Code: Select all
<%
	sub ErrorHandler()
		dim objErr
		dim bodyText
		set objErr=Server.GetLastError()

		bodyText = join(array(name & " has encountered the following error on " &  _ 
													Request.ServerVariables("URL"), _
													"ASPCode=" & objErr.ASPCode, _
													"ASPDescription=" & objErr.ASPDescription, _
													"Category=" & objErr.Category, _
													"Column=" & objErr.Column, _
													"Description=" & objErr.Description, _
													"File=" & objErr.File, _
													"Line=" & objErr.Line, _
													"Number=" & objErr.Number, _
													"Source=" & objErr.Source), "
")
		
		SendEmail getValue(user, "email"), "tegwe002@umn.edu", "", "", "Child Lit Error", bodyText, ""
		set objErr = nothing
		
		response.redirect "Error.asp"
	end sub
%>
The output page looks like this:
Code: Select all
<html>
<head>
<%
	dim myDate
	dim PageTitle
	 myDate = "February 27, 2004"
	 PageTitle = "Error"
%>




<% ErrorHandler %>

</head>

<body bgcolor="#ffffe0" text="#660000">




<h2>Error Report</h2>
The action you requested has performed an error. The site administrator has been notified and will contact you when the error has been rectified or if she has any questions.


We appologize for the inconvience. 









</body>
</html>
and yes my tech guy used the IIS manager (ver 5) for the 500;100 error.

The other thing, that I forgot to mention, is that when he got the file selector popup the options for file types were HML, HTML and ALL FILES.
and, Mozilla doesn't know what to do with the file and pops open a dialog box saying that it's an octet stream that it doesn't know what to do with.

It's like the server doesn't understand that it's an ASP file so it's not passing the page to the ASP server.

jakyra (who needs to work on giving enough info)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
servergetlasterror

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT!!!! Send HTTP request from one web server to another server chandra.nowduri ASP.NET Forum 1 Aug 7th, 2006 19:18
Need to process data on one server, utilize it on another server ... can it be done? jaobrien Classic ASP 1 Dec 6th, 2005 00:58
XP as Server jgbarber65 Hosting & Domains 1 Dec 3rd, 2005 16:43


All times are GMT. The time now is 04:04.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42