Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debugging ASP (aside from error 500 mesgs)

Status
Not open for further replies.

BlueScr33n

Instructor
Feb 10, 2003
78
US
A bit new to this, but I was wondering what the accpeted, or at least widely used methods of debugging asp files were. Currently I'm only getting HTTP 500 - Internal server errors which aren't exactly descriptive.

Thanks for reading.
 
Different ppl will use different methods. I have always just used the old fashioned...

document.write myVariable
document.end

at any problem point in my code. I then move it around to see where it's failing. I also use

document.write "1"
..
..
..
document.write "2"

and so on to see where I am when I use loops.... Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Working with preexisting code (inhereted unfortunatly), and supposedly just stopped working:

--- think it had to do with a hotfix applied to an IIS machine that eliminated the ability to write to a file. I've checked the permissions for the log.txt (read, read/exe) are enabled for everyone - easy fix would be to grant write to the file so the script would be able to overwrite the previous number in there with the incremented one, but the admin side of me has a hard time coming to grips with granting write permission to anything. Any ideas?

The original code:

Dim fso, ts
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

LogFile = "/tracking/Log.txt"
Set fso = CreateObject("Scripting.FileSystemObject")

Set ts = fso_OpenTextFile(LogFile, ForReading)
StartNumber = ts.ReadLine()
ts.Close

StartInt = eval(StartNumber)
EndInt = StartInt+1

Set ts = fso_OpenTextFile(LogFile, ForWriting)
ts.WriteLine(EndInt)

response.write &quot;EndInt = &quot;&EndInt&&quot;<br>&quot;
ts.Close



Again, thanks for the time/help given.
 
You likely ran a security analyzer, or Check front page extensions (and let it tighten security)
As you suspected, the file must have write permissions, as you are trying to write to the file -- ts.WriteLine(EndInt)



 
Had to give write permissions to the txt file - aside from that, I'll have to check into FP Ext, and whether someone decided to run the lockdown wiz.

Thanks for the help!
 
I find that sometimes all I need to do is to put a response.flush at the very start of the page. This sends the headers and puts the server in a position that it can't redirect the client page. This means that it has to dump the error to the client. While debugging, this can be a very useful trick. Just make sure you pull it before distributing the page.
Code:
Option Explicit
Response.Write(&quot;TESTING: Force Error Display&quot;):Response.Flush
Another useful one is for sql strings. I often have a sql failure and need to know what the sql was that caused the error so that I can test the SQL by itself. In that case:
Code:
response.write(replace(replace(sql,&quot; &quot;,&quot;&nbsp&quot;),vbnewline,&quot;<br>&quot; & vbnewline)):response.flush
wait a minute...
Code:
response.write(server.htmlencode(sql)):response.flush
:~/ Now I feel like a nob. I've been using the replace for almost a year. Its not like I didn't know about htmlEncode.

Anyway, you get the idea. Same as the good old fashioned write some text, except, don't forget that you can also write variable values out as well.

Now if you will excuse me I have to go cry over the replace thing... _______________________________________
Ignorance is a beautiful thing:
You don't know what you can't do...
 
Hehehehe..

Thanks again MWolf, HectorShuckle, ufobaby, and kavius for the help, links and advice. I've got a few other pages that on occasion throw the Internal Server error, at least unless you let them sit open in a browser for 4-5 minutes - So I'll be back. =P
 
Sorry - have I missed something - I use Visual InterDev and put server debugging on. When everything is debugged I copy whole application back to live site and turn debugging off
 
Don't have Visual InterDev for development/debugging - only Frontpage unfortunatly.
 
One more little snag,

I've noticed that after a successful log on to a secure area of the site, pages that should be available to me return the follow messege:

&quot;An error occurred on the server when processing the URL. Please contact the system administrator.&quot;

The strange thing is, if I leave the browser window open for a few minutes, and then click on one of the links that returned the above messege, I am able to view the information without error.

These pages are grabbing information from an Access database on the web server using the follow code:

Dim Cnn,RS
Set Cnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set RS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Cnn.Open &quot;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=&quot; & Server.Mappath(&quot;../Database/Order.mdb&quot;) & &quot;;&quot;

Rs.Cursorlocation=3
Rs.Open &quot;SELECT RawData,OrderID FROM RawOrders Where Status=FALSE&quot;,Cnn,0,3
Set Rs.ActiveConnection=Nothing
Cnn.Close


The information being stored above is then being used and formatted as follows:
-----------------------------
Begin Section 1:
Y=0
Rs.MoveFirst
While Not RS.EOF
'Ignore test orders
CurrentOrder = RS(&quot;RawData&quot;)+vbCr
if (instr(1,CurrentOrder,&quot;TestOrder&quot;) = 0) then
Response.Write(&quot;<input type=checkbox value=&quot; & RS(&quot;OrderID&quot;) & &quot; name=&quot; & RS(&quot;OrderID&quot;) & &quot;>&quot; & RS(&quot;OrderID&quot;) & vbCr)
Y=Y+1
end if
RS.MoveNext
Wend

End Section 1:
-----------------------------
-----------------------------
Begin Section 2:

CurrentOrder=&quot;&quot;
Y=0
Rs.MoveFirst
While Not RS.EOF
CurrentOrder = RS(&quot;RawData&quot;)+vbCr
if (instr(1,CurrentOrder,&quot;TestOrder&quot;) = 0) then
Response.Write(CurrentOrder)
end if
Y=Y+1
RS.MoveNext
Wend
RS.Close

End Section 2:
-----------------------------

I appreciate the time you've already taken to read through this, and would be appreciative of any help/pointers/links or suggestions given on this. Again, thank you.
 
I don't see where cnn is being set to nothing.....

Set cnn=nothing

If you don't do that, then you have to wait for IIS to drop the object. You could be running out of ado connections, which would give you the error, waiting a few minutes gives IIS a chance to drop the object.

Usually if you look further down on the error page, it'll give you a line number, showing where the error occurred.
 
HectorShuckle is right , also u'll ned to check permissions on the &quot;temp&quot; directory as DSN less connections use this directory to write info... give the directory &quot;everyone&quot; rights

also on your earlier problem of custom error page , did the link i gave help ? did u try it ?

[cheers]
Niraj [noevil]
 
ufobaby,
That page you sent earlier I'll be going through with some of the other pages that aren't working 100% of the time. Currently the friendly error mesgs are shown - which I'll be changing tomorrow on the staging machine so I can further see what's going wrong.

In addition, using a 500 page that displays as much debugging code as possible is going to be another step that I'll be trying out.

Thanks again providing me with the heads up on what steps can be done to resolve or at least find out what's going wrong - I hope I'll have the chance to return the favor in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top