[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

IIS 5.0 Custom Error Page doesn't execute as desired.

Asked by NTJOCK in Active Server Pages (ASP)

Tags: error, iis, custom, page

I used to have a custom error page in ASP on IIS 4.
When we upgraded to IIS 5 it stopped working.
I'm puzzled as to why it's not working and I've searched hi and low for a solution.  I consider this difficult because I have not been able to locate the answer and the page works when called directly.

1) Desired Result: Upon an error, this page is called and an email is sent detailing the problem.  The user sees a friendly error page.  Critical details are hidden from prying eyes.

What's happening:
- When an error occurs, the page loads, but doesn't send the email or display the error.  
- When the page is called directly  www.server.com\errors\404.asp  It works and sends the email.
- when the page is called by IIS in response to an error, nothing.  No error, no string, no email.

Language used, VB Script.
Used to be CDONTS, upgraded to new CDO model (really easy actually).

What I've tried:
I've hardcoded some response.write strings to force the output and try to trace the issue.

Server Environment:
Capable hardware, running 2003 Web Server Edition.
Stable production web server
Acceptable to good security configuration.
We have the machine audited weekly.
We are running the lockdown script to disable ports.
Server is on a firewalled network.  So when we look at the server directly the 192.168.1.x test will spit out the error directly so we can see it.

Other observations:
The page works when called directly.
Emails work from other functions on the site.
Removing all code except the email generator results in the same activity, no email is sent.

Hunches:
1) Server configuration that I don't know about.
2) Restriction in execution capabilities during error... ?
3) Minor mistake in code somewhere.

Live example ommitted because when I get it working I don't want 33000 emails.

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<head>
<META NAME="ROBOTS" CONTENT="NOINDEX">
<title>A system Error has occured.</title>
</head>
<body >
<%
    Dim objASPError, blnErrorWritten, strServername, strServerIP, strRemoteIP
 
  'If Response.Buffer Then
  '  Response.Clear
  '  Response.Status = "Server Error"
  '  Response.ContentType = "text/html"
  '  Response.Expires = 0
  'End If
Set objASPError = Server.GetLastError
  Dim strErrorDescription
  strErrorDescription = "Category=" & objASPError.Category & vbCrLf
  If objASPError.ASPCode <> "" Then
    strErrorDescription = strErrorDescription & "Code=" & objASPError.ASPCode & vbCrLf
  End If
  strErrorDescription = strErrorDescription & "Number=(0x" & Hex(objASPError.Number) & ")" & vbCrLf
  strErrorDescription = strErrorDescription & "Description=" & objASPError.Description & vbCrLf
  If objASPError.ASPDescription <> "" Then
    strErrorDescription = strErrorDescription & "ASP Error Description=" & objASPError.Description
  End If
  blnErrorWritten = False
  strServername = LCase(Request.ServerVariables("SERVER_NAME"))
  strServerIP = Request.ServerVariables("LOCAL_ADDR")
  strRemoteIP =  Request.ServerVariables("REMOTE_ADDR")
  If objASPError.Source <> "" Then
    strErrorDescription = strErrorDescription & "File=" & objASPError.File & vbCrLf
    If objASPError.Line > 0 Then
      strErrorDescription = strErrorDescription & "Line=" & objASPError.Line
    End If
    If objASPError.Column > 0 Then
       strErrorDescription = strErrorDescription & ", Column= " & objASPError.Column
    End If
    strErrorDescription = strErrorDescription & vbCrLf
    strErrorDescription = strErrorDescription & "Code:" & vbCrLf & Server.HTMLEncode(objASPError.Source) & vbCrLf
    If objASPError.Column > 0 Then
      strErrorDescription = strErrorDescription & String((objASPError.Column - 1), "-") & "^" & vbCrLf
    End If
    blnErrorWritten = True
  End If
  If Not blnErrorWritten And objASPError.File <> "?" Then
    strErrorDescription = strErrorDescription & vbCrLf & "Filename=" & objASPError.File & vbCrLf
    If objASPError.Line > 0 Then
      strErrorDescription = strErrorDescription & "Number=" & objASPError.line
    End If
    If objASPError.Column > 0 Then
      strErrorDescription = strErrorDescription & ", Column=" & objASPError.Column
    End If
    strErrorDescription = strErrorDescription & vbCrLf
  End If
  Dim mymail, strBody
  Set mymail = Server.CreateObject("CDO.message")
  mymail.From = "ommitted"
  mymail.To ="ommitted"
  mymail.Subject = "ASP Error Occurred @"&now&" on "&date
  strBody = "An error occured on server=" & strServername&vbcrlf&" IP Address=" & strServerIP&vbcrlf
  strbody = strbody &vbcrlf& " Client IP=" & strRemoteIP&vbcrlf
  strBody = strBody & " at " & Now() & vbCrlf
  strBody = strBody & "BrowserType=" & Request.ServerVariables("HTTP_USER_AGENT") & vbCrlf
  strbody = strbody & "Method=" & Request.ServerVariables("REQUEST_METHOD") & vbCrlf
  strbody = strbody&"URL Called was: "&request.servervariables("URL")&vbcrlf
  strbody = strbody&"Query was: "&request.servervariables("query_string")&vbcrlf
  strbody = strbody&"Path was: "&request.servervariables("Path_translated")&vbcrlf
  strbody = strbody&"Referred by: "&request.ServerVariables("HTTP_REFERER")&vbcrlf
  strbody = strbody& "Error Message:"&vbcr&strErrorDescription & vbCrLf
  if sqlstring<>"" then   strbody = strbody& "SQL"&sqlstring
  mymail.textBody = strBody
response.write(strbody)
  mymail.Send
  Set mymail = Nothing
  if instr(1,strremotip,"192.168.1",1)>0 then response.write(strbody)

[+][-]11/24/05 10:50 AM, ID: 15357761Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Active Server Pages (ASP)
Tags: error, iis, custom, page
Sign Up Now!
Solution Provided By: leechoonhwee
Participating Experts: 1
Solution Grade: B
 
[+][-]11/24/05 03:37 PM, ID: 15358466Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/24/05 04:43 PM, ID: 15358568Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/24/05 07:24 PM, ID: 15358875Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/24/05 08:46 PM, ID: 15359180Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/24/05 11:34 PM, ID: 15359478Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93