Custom Error Pages Error

Hey guys, I bet someone can help me with a weird little problem I'm having.

I'm using a custom error page to catch .ASP errors and things have been working well until today.

All of a sudden, when an error transfers the browser to the custom error page the page doesn't display. Instead the source code shows up on the screen. Sometimes the browser responds by asking you to save or open the download.

This is weird because it had been working fine for several weeks.

My error handler page is an .ASP and I'm trying to have the details of the error emailed to me using CDONTS.

Also the server.getLastError method doesn't seem to work. I assume this is becuase that feature is disable on the IIS server.?.?

Any suggestions?
 
You would get this if your page wasn't named *.ASP or if ASP processing was disabled... but you say it's all okay? I would make a test error trapping page without CDONTS and all the other stuff you have in it, and just Response.Write "Hello, you got an error." Then, slowly add stuff to it, such as the error label, etc. You might expose the problem that way. Also, if you have ON ERROR GOTO NEXT at the top of the page, get rid of it. That may also expose an error on the page.
-Dave
 
WineIsGood said:
You would get this if your page wasn't named *.ASP or if ASP processing was disabled... but you say it's all okay? I would make a test error trapping page without CDONTS and all the other stuff you have in it, and just Response.Write "Hello, you got an error." Then, slowly add stuff to it, such as the error label, etc. You might expose the problem that way. Also, if you have ON ERROR GOTO NEXT at the top of the page, get rid of it. That may also expose an error on the page.
-Dave

I commented out the CDONTS code and the problem persited. My page is .asp and there isn't an ON ERROR GOTO NEXT statement.

Very strange. The problem began when I added the CDONTS code, however when I commented it out the problem continued. Then I tried removing all my asp tags completely and the problem clears up.

OK, I have tracked the problem to bodyformat property of the CDONTS object. If I remove this line objMail.bodyformat = 0 then the page displays properly. I'm still testing...

This works fine on my local IIS setup. Weird..
 
Now this is really blowing my mind.

It appears the problem is based on the number of lines of code in my error handler page.

It doesn't matter what the line of code contains, including comments. If there are more than 5 lines of code the problem I described in my first post happens.

I've been testing this thing for hours now and I think I must be wasting my time.

I've never seen anything like this. Once again it works fine on my local IIS setup. I think I better stop playing with this one for a while.

If anyone has heard of an issue like this please let me know
 
Hi

Could you point me to the page where this error is occuring or submit a ticket. It could very well be an IIS related problem which we would need to correct manually on the server
 
Here is the source code:

This page is located at queenofpersia.com/500.asp

I have some broken asp code on queenofpersia.com/test.asp that I've been using to test the 500.asp page.

I have discovered if I move the CDONTS portion of the code into the body of the html document the page will display. However, all the ASP code on the page is ignored.

Alan

<%
dim objErr, objMail, html
set objErr=Server.GetLastError()
Set objMail = CreateObject("CDONTS.NewMail")
objMail.From = "[email protected]"
objMail.to= "[email protected]"
objMail.BodyFormat = 0
objMail.MailFormat = 0
objMail.Subject = "QOP Error 500"
html = "<font face='Verdana, Arial, Helvetica, sans-serif'><br>"
html = html & "<p>Error occured at: " & now
html = html & "<p>Referred from: " & request.ServerVariables("HTTP_REFERER")
html = html & "<p>Url: " & request.ServerVariables("URL")
html = html & "<p><b>Category: </b></p>" & objErr.Category
html = html & "<p><b>Filename: </b></p>" & objErr.File
html = html & "<p><b>ASP Code: </b></p>" & objErr.ASPCode
html = html & "<p><b>Number: </b></p>" & objErr.Number
html = html & "<p><b>Source: </b></p>" & objErr.Source
html = html & "<p><b>LineNumber: </b></p>" & objErr.Line
html = html & "<p><b>Column: </b></p>" & objErr.Column
html = html & "<p><b>Description: </b></p>" & objErr.Description
html = html & "<p><b>ASP Description: </b></p>" & objErr.ASPDescription
html = html & "<blockquote>"
html = html & "All HTTP: " & Request.ServerVariables("ALL_HTTP")
html = html & "</blockquote></font>"
objMail.Body = html
objMail.Send
objErr.clear
Set objMail = Nothing
Set objErr = Nothing
%>

The rest of the Html on the page
 
Looks good to me... Did you forget to write Server.CreateObject when instantiating your mail object? I only see CreateObject. The only thing I would recommend would be to move the objErr.Clear and Set objErr=Nothing lines immediately after the last html variable addition, just before the objMail.Body= and objMail.Send. Generally speaking, you want to release the resources you previsouly allocated as soon as possible... and, when error objects are concerned, I like to clear the last error and release that object as soon as possible, given that yet another error could occur within my code. So, my only suggestion would be to reorganize it like this:

<%
dim objErr, objMail, html
'Grab the error stuff and quickly release
set objErr=Server.GetLastError()
html = "<font face='Verdana, Arial, Helvetica, sans-serif'><br>"
html = html & "<p>Error occured at: " & now
html = html & "<p>Referred from: " & request.ServerVariables("HTTP_REFERER")
html = html & "<p>Url: " & request.ServerVariables("URL")
html = html & "<p><b>Category: </b></p>" & objErr.Category
html = html & "<p><b>Filename: </b></p>" & objErr.File
html = html & "<p><b>ASP Code: </b></p>" & objErr.ASPCode
html = html & "<p><b>Number: </b></p>" & objErr.Number
html = html & "<p><b>Source: </b></p>" & objErr.Source
html = html & "<p><b>LineNumber: </b></p>" & objErr.Line
html = html & "<p><b>Column: </b></p>" & objErr.Column
html = html & "<p><b>Description: </b></p>" & objErr.Description
html = html & "<p><b>ASP Description: </b></p>" & objErr.ASPDescription
html = html & "<blockquote>"
html = html & "All HTTP: " & Request.ServerVariables("ALL_HTTP")
html = html & "</blockquote></font>"
objErr.clear
Set objErr = Nothing
'Send mail
Set objMail = Server.CreateObject("CDONTS.NewMail") 'Fixed here
objMail.From = "[email protected]"
objMail.to= "[email protected]"
objMail.BodyFormat = 0
objMail.MailFormat = 0
objMail.Subject = "QOP Error 500"
objMail.Body = html
objMail.Send
Set objMail = Nothing
%>
But, in reality, I can't see why your code shouldn't work.
-Dave
 
I'm not sure why I don't usually write server before Creating the CDONTS mail object. It just works on my other pages. I changed it to server.CreateObject and the problem still persists.

I think it must be something with IIS. Funny thing is if you go directly to the page without an error (type in the url) it works fine. If I use a server.transfer() from another page, it works fine. However, when an error occurs and IIS transfers to the page it doesn't work.

Thanks for the help Dave. I checked out your website and I love a good wine. I will share my pedestrian tastes with you.

Alan
 
Now this is strange. See what I've got as a response headers from that page:
Code:
Content-Length: 14754
Content-Type: application/octet-stream
Cache-Control: private
Server: Microsoft-IIS/5.0
X-Powered-By: ASP.NET
Via: 1.1 Thor_5med1 (NetCache NetApp/5.3.1R3D2)

Now, I've tried to get headers from another ASP page. Here:
Code:
Content-Type: text/html
Server: Microsoft-IIS/5.0
X-Powered-By: ASP.NET
Via: 1.1 Thor_5med1 (NetCache NetApp/5.3.1R3D2)
See the difference in Content Types? Also for a html page, content type "application/octet-stream"???


And ... Not right on topic, but about difference between CreateObject and Server.CreateObject. The last is the one that should be used in ASP. The first one belongs to VBAcript itsef and the poblem with it, that you have always set your objects to Nothing, while the second one belongs to IIS and it frees any objects when they go out of scope (or at the end of page)
 
Hmmm... are you sure the script resides within valid html and body tags? Try to make sure the page is simple at first -- html, body, and hardly any meta tags at all, then place your script directly between then body tags. You posted a good portion of the code, but would it be possible to simply attach the whole file to a message post, so we can see the headers and all?
-Dave
ps. Thanks for checking out my site (and finding that nasty time-zone bug I had in there from my previous hosting company! Go JodoHost!)
 
Yash said:
Couldn't find any problem with the server configuration. ASP working fine. We even uploaded a test file: http://queenofpersia.com/testasp.asp

Try maybe renaming 500.asp to error500.asp (what most customers do) and update your CP

OK, I renamed the error page to error500.asp and updated the cp.

It's still the having the same problem. Here's an easy way to test it:
http://queenofpersia.com/product-details.asp if you hit this page without any querystrings it will produce an error.

Dave, if you want to see the full source code of my error500.asp page then click that link abov. Either the source code will display on the screen or you will be able to save the entire file to disk.

Yash, this works fine on my local IIS setup. I don't think my domains have details asp error message enabled. Could this be the cause? Can you enable them for me?

Alan
 
Wow.. that's strange. Just try this simple page:

<html>
<body>
<%
Dim objErr
Set objErr = Server.GetLastError()
Response.Write "You just experienced error: " & objError.Description
Set objError = Nothing
%>
</body>
</html>

I know it sounds strange, but just try this code and nothing more. If it works, add other objErr properties one at a time. If they all work too, add the CDONTS mail object to it, etc. etc.
-Dave
 
Ok, here is what I tried:

<html>
<body>
<%
response.write("This is driving me nuts")
%>
</body>
</html>

The ASP code is not being processed by the server. Even this simple page (That is the complete code of my error500.asp page) will not work when IIS transfers me to the error page.

I have decided that this must be an issue with the server and not my code. Once again the page works fine if you type in the URL but if IIS transfers there because of error 500 the asp code is not parsed by the server. What's the deal? This is driving my nuts.

Yash, please have another look and see if you can figure it out.

Alan
 
Wait -- did you set IIS up as a transfer or as a redirection? If the script engine generates an error, it will launch the corresponding error page, not IIS. You need IIS to redirect to the custom error page so it knows to process the new ASP information. You can try it by making a 404 error page, for example, and trying to transfer to an unknown page. IIS is not responsible for the script response... you need to perform a real URL redirect for IIS to process the custom page. Try adding these lines to the top of your custom error script (they need to be the very top lines since HTTP headers are sent before any content):
<%
Response.AddHeader "Status Code", "200"
Response.AddHeader "Reason", "OK"
Option Explicit
On Error Resume Next
Response.Clear
Dim objError
Set objError = Server.GetLastError().... etc.
%>
Now you need to tell IIS to go to your URL (change the type to URL) upon the error. You will probably have to restart the IIS service for this to take effect. Also, make sure the machine you're testing it on doesn't have the IE option called "Show Friendly HTTP Errors" turned on. Turn that off.
Let me know,
-Dave
 
I'm extremely sorry for the problem. We corrected it. IIS was indeed not executing your code and it had escaped our attention.
 
Back
Top