Debugging an ASP Web Page

 

If you are about to debug an ASP web page that resides on a Windows 7 platform (IIS 7.5) then hurry over and visit http://www.dondraper.com/2011/01/500-internal-server-error-from-iis-7-5-on-windows-2008-r2/   According to Microsoft, if you have an ASP web page that needs debugging, all you need to do in the IIS Manager is "Send Errors to Browser" in ASP settings. Next, run your ASP page in your browser and the offending line of code will show up in your browser! Unfortunately, it doesn't work. Don Draper states in his blog that Microsoft's advice does work in Windows 7 (except, it doesn't work for me), but in Windows Server 2008 R2  you also have to edit the 500 Error page and change the error response to "Detailed Error". I added Don's suggestion to my Windows 7 setup, and I got detailed error messages in my browser!

I was using an asp page written by somebody else for my visitor's blog. Unfortunately, I came under attack (a ddos attack) by some evil doers who made use of my visitor's blog. The visitor's blog allowed anonymous posts, and my attackers were posting (nonsense, the posts consisted of random letters) non-stop, at high speed. I let the attack go on for several hours, just in case the attackers were attacking me by mistake and might stop once they figured out what they were doing. Eventually I took down my visitor's blog.

I thought about not putting back a visitor's blog, since my guestbook was getting lots of hits and the posters always left comments; comments ranging from shameless advertising to comments about Rush Limbaugh. I decided I'd put a visitor's blog back up, using another ASP page. I found an ASP forum, Snitz Forum 2000, that had security controls needed to stop another ddos attack. Snitz forum also allows forum members to e-mail each other, using a forum e-mail form. The code underneath the e-mail form creates an object that has all the properties needed for sending e-mail; e.g., smtpservername, smtpserverport, etc.  When I sent an e-mail message as member "dave" (that's me, and I have admin rights on the server, the system, the forum, etc.) it crashed with an internal server error (error 500). I commented out the link to another ASP page that had the code for sending out e-mail, and replaced it with VBS code I found at http://www.w3schools.com/asp/asp_send_email.asp ; that worked.

Unfortunately, when I registered to the forum as a non-admin, I wasn't able to send form e-mail; crashed with a 500 error. I searched the Internet for possible causes; none of them panned out. So I figured I would have to debug this ASP code, and (as I said in the introductory paragraph of this blog) and set debugging in the ASP module to send errors to the browser. I sent a message as a non-admin and it still crashed without giving me any error messages, beyond saying it was a 500 error. Being unable to debug the code I tried "fixing" everything that could be causing the problem; didn't work.

Today I went back to researching how to debug and ASP page on IIS 7.5  When I cam across Don Draper's blog I gave it a try and I got a line number in the error message! I took a look a the line of code and it had nothing to do with what I though the problem might be. It turns out that non-admin registration wasn't setting one of the values in application's database. I created a default value for the database property that was blowing up, and all of a sudden I can send e-mail as a non-admin; the application doesn't crash. It's really important to have debugging ability for your code, so check out http://www.dondraper.com/2011/01/500-internal-server-error-from-iis-7-5-on-windows-2008-r2/ if you need to debug some ASP code on Windows 7 or Windows 2008 R2.

 

Back To My Blog Page