ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 4 votes, 3.75 average. Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 16th, 2005, 12:21 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,067 selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 8 h 28 m 37 sec
Reputation Power: 185
Debugging techniques

Various debugging techniques can be useful in helping you to diagnose faults with your ASP scripts. I'd like to open the floor to our resident gurus and ask for suggestions and top tips to help our forum users debug their ASP scripts more effectively

I would like to start with ASP error handling. To initiate error handling you should add the following line to your script:

On Error Resume Next

The line tells the ASP interpreter to continue with the script even if there is an error. You can find out more about error handling here:

http://www.aspdev.org/articles/asp-error-handling/

There are various reasons why you should want to implement error handling. However, if you are new to ASP, this line should be avoided until you find the need to use it to trap and handle errors properly

More importantly, if you are experiencing problems with your ASP script, including "On Error Resume Next" in your script can stop the browser from displaying the error message and might stop you from tracking down the problem

I would strongly recommend against using ASP error handling if you are new to ASP or if your application is in development
Comments on this post
KuraofTyren agrees:
__________________
selwonk

If I've posted some code above, you might think it looks a bit simplistic. It might be. I'd rather people tried the next step themselves rather than getting a full solution on a plate. That way they learn more!


Reply With Quote
  #2  
Old February 18th, 2005, 07:22 AM
anandham anandham is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Mumbai
Posts: 40 anandham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 10 m 2 sec
Reputation Power: 0
Send a message via Yahoo to anandham
Cool

Hi MK,
U have started a nice discussion.. When we used to develop somehuge application we used to
have On error Resume Next commented in the first place . so u can identify the error,line of error & what
type of error.. but when everything completed we remove the comment on the On error Resum next so
the ourside world never knows the error.. that's a pretty good trick for error free code..
Let me tell u me way of debugging..when there is an error occurs & u don't know the reason just
put thread in forums.aspfree.com ..that's it ur error will be solved overnight..
I'm using Microsoft Interdev to create my ASP application..there is a tab to choose Quick View..
I frequently go to this and it throws me all javascript & html errors.
That's it..

anandham

Reply With Quote
  #3  
Old February 18th, 2005, 08:19 AM
tbango tbango is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 9 tbango User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 19 m 55 sec
Reputation Power: 0
I work on a large asp/database program. We have a debug session variable. When the session variable turns debugging on On Error Resume Next is not part of the code. This also protects the programmers from left over response.write statements that were put in for debugging. If debug isn't on they don't print. We use this because there are so many asp programs and stored procedures working in this program that errors crop up from usage we don't expect. This allows us to quickly check out problems.

Reply With Quote
  #4  
Old February 18th, 2005, 09:04 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,067 selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 8 h 28 m 37 sec
Reputation Power: 185
Sounds similar to one of my projects...
Code:
SHOWDEBUG = 0 ' 0-Off, 1-In source, 2-On page
...
Sub Debug(str_Message)
Select Case SHOWDEBUG
Case 1
	Response.Write(vbcrlf & "<!-- " & str_Message & " -->" & vbcrlf)
Case 2
	Response.Write(vbcrlf & "<font size=""2"" face=""Courier new"" color=""red"">" & str_Message & "</font><br>")
End Select
End Sub

Reply With Quote
  #5  
Old February 24th, 2005, 04:17 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 49 m 54 sec
Reputation Power: 10
On the subject of ASP debugging.... didn't the now-discontinued Microsoft VisualInterDev support server-side VBS debugging in a very similar fashion to the way VS2003 does.

Just wondering really... if it does, I'd certanly look into finding InterDev in the bargain bins

Reply With Quote
  #6  
Old February 24th, 2005, 04:23 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,067 selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 8 h 28 m 37 sec
Reputation Power: 185
I think you're right. If anybody is interested, I also wrote a client-side Windows application that collects debug information from a SQL Server table and displays it on the desktop. Useful for debugging remote or local applications. You add a single #include to your ASP script and then add debug statements like this:
Code:
TL_AppendTraceLog 0, "YourScript.asp", "Starting script..."
It generates a visual debug report coloured depending on the debug level (in this case 0 - information)
Comments on this post
thaminda agrees: Useful information

Reply With Quote
  #7  
Old March 11th, 2005, 11:26 AM
PhilCollins99's Avatar
PhilCollins99 PhilCollins99 is offline
The Constant Student
ASP Free Novice (500 - 999 posts)
 
Join Date: Aug 2004
Location: England
Posts: 914 PhilCollins99 User rank is Sergeant Major (2000 - 5000 Reputation Level)PhilCollins99 User rank is Sergeant Major (2000 - 5000 Reputation Level)PhilCollins99 User rank is Sergeant Major (2000 - 5000 Reputation Level)PhilCollins99 User rank is Sergeant Major (2000 - 5000 Reputation Level)PhilCollins99 User rank is Sergeant Major (2000 - 5000 Reputation Level)PhilCollins99 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 5 h 43 m 35 sec
Reputation Power: 29
Wink Debugging For Me

Bearing in mind I only work with pages of ASP with Javascript and HTML at the moment, I tend to simplify things as much as possible. As I think most people that use this site are in a similar position, I will explain a little further.

ASP page
If I know an ASP page is causing me difficulties I put a Response.End in the page and move it down a line until I find the offending line. Once I find the offending line I then copy out the code, if possible, and I produce a more simple page which allows me to identify exactly what is going on. I use response.write to output variables or just messages to the actual page, which usually gives me enough information to tell me why I'm being such as silly little girl!!! This approach is not always possible but it certainly helps get things off the ground.

Javascript
Similar to the above but I use alert() statements and response.end to output what is going on and this is usually enough to give me a clue. Again, I try to move the JavaScript to a new page and get it working in a simpler fashion.

I always try to separate as much of the code as possible. If I know a function or sub routine is the offending item then again, I try and call this from a simple page and output the results step by step.

I know this is very basic, but I hope this is helpful to others.
Comments on this post
selwonk agrees: Nice...
EasyMeat agrees!

Reply With Quote
  #8  
Old March 11th, 2005, 04:33 PM
amaloo09 amaloo09 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 7 amaloo09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 47 sec
Reputation Power: 0
Smile Hey thanks a lot for that little hint of your's using the "Response.End" technique.

Quote:
Originally Posted by PhilCollins99
Bearing in mind I only work with pages of ASP with Javascript and HTML at the moment, I tend to simplify things as much as possible. As I think most people that use this site are in a similar position, I will explain a little further.

ASP page
If I know an ASP page is causing me difficulties I put a Response.End in the page and move it down a line until I find the offending line. Once I find the offending line I then copy out the code, if possible, and I produce a more simple page which allows me to identify exactly what is going on. I use response.write to output variables or just messages to the actual page, which usually gives me enough information to tell me why I'm being such as silly little girl!!! This approach is not always possible but it certainly helps get things off the ground.

Javascript
Similar to the above but I use alert() statements and response.end to output what is going on and this is usually enough to give me a clue. Again, I try to move the JavaScript to a new page and get it working in a simpler fashion.

I always try to separate as much of the code as possible. If I know a function or sub routine is the offending item then again, I try and call this from a simple page and output the results step by step.

I know this is very basic, but I hope this is helpful to others.



Hey thanks a lot for that little hint of your's using the "Response.End" technique. I certainly will use that code. Thanks again.

Reply With Quote
  #9  
Old March 21st, 2005, 10:58 AM
orly_otero orly_otero is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 9 orly_otero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 23 m 23 sec
Reputation Power: 0
Hi all,
Script Debugger IDE can be found at http://www.script-debugger.com/ which enables Client and Server side debugging features.
A free script Client and Server sides script debugger can be found at http://www.microsoft.com/downloads/...&displaylang=en

Regards,
Orlando Otero

Reply With Quote
  #10  
Old May 16th, 2005, 10:32 AM
ASP-Hosting.ca ASP-Hosting.ca is offline
Need hosting? I can help.
ASP Free Novice (500 - 999 posts)
 
Join Date: Sep 2003
Posts: 826 ASP-Hosting.ca User rank is Private First Class (20 - 50 Reputation Level)ASP-Hosting.ca User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 17 h 50 m 37 sec
Reputation Power: 7
The simplest way to debug ASP code is to use Response.Write statements along with Response.End.
Comments on this post
rhyno agrees: I agree
kanenas.net agrees!

Reply With Quote
  #11  
Old May 26th, 2005, 04:36 AM
leuvenaar's Avatar
leuvenaar leuvenaar is offline
Frustrated Wizard
ASP Free Regular (2000 - 2499 posts)
 
Join Date: Apr 2005
Posts: 2,408 leuvenaar User rank is Sergeant (500 - 2000 Reputation Level)leuvenaar User rank is Sergeant (500 - 2000 Reputation Level)leuvenaar User rank is Sergeant (500 - 2000 Reputation Level)leuvenaar User rank is Sergeant (500 - 2000 Reputation Level)leuvenaar User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 22 h 57 m 8 sec
Reputation Power: 15
What i do is going step by step through the code by commenting out code lines.
Just starting with everything commented out and then going through it, uncommenting parts / lines of code. Then the place of the error will come up.

Very easy to use.
Comments on this post
PhilCollins99 agrees: I also do this. It works well for me most of the time.

Reply With Quote
  #12  
Old May 27th, 2005, 07:49 AM
catdogfight catdogfight is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: istanbul
Posts: 15 catdogfight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 28 m 50 sec
Reputation Power: 0
this function can be useful.

(for "logical" errors.)
Code:
    <script language="jscript" runat="server">
    /*********************************
    anov (aka. "catdogfight")
    15:39 27.05.2005 : posted to aspfree forum
    **********************************/
    function log_(p){
    
    	/**************************
 		  Options
    	***************************/
    	var logging = true ; //Logging is open?
    
    	var file = "" ;  //filter with file name
    
    	var filter = null ; //filter with regex
    
    	var file_name = String( Request.ServerVariables("SCRIPT_NAME") ) ;
    
    	var file_name_begin = file_name.lastIndexOf("/") + 1 ;
    
    	file_name = file_name.slice( file_name_begin ) ;
    
    	/******************************/
    
    	if(!logging) return true;
    
    
    
    	if(file!="")
    	{
    		//Response.Write( file.indexOf(file_name)==-1 )
    		if(file.indexOf(file_name)==-1) return false ;
    	}
    
    	//debugging(filter instanceof RegExp )
    
    	if(filter instanceof RegExp)
    	{
    		if( filter.test( String(p) ) == false )
    		{
    			return false ;
    		}
    	}
    
    
    	var path = Server.MapPath(".")+"\\"+"log.txt"
    
    	var fso = Server.CreateObject("Scripting.FileSystemObject");
    	var f ;
    
    	if(fso.FileExists(path))
    	{
    		f = fso.OpenTextFile(path,8);
    	}
    	else
    	{
    		f = fso.CreateTextFile(path,true) ;
    	}
    
    	try
    	{
    	f.Writeline(p) ;
    	}
    	catch(e)
    	{
    		Response.Write("<h1>" + p + "</h1>" );
    	}
    	f.Close() ;
    
    	delete f,fso;
    }//end function
    
    function alert_( p )
    {
    	var lt = String.fromCharCode(60); // <
    	var gt = String.fromCharCode(62); // >
    	var t  = String.fromCharCode(39); // '
    
    	Response.Write(lt+"script"+gt+"alert('" + p + "')"+lt+"/script"+gt);
    }
    </script>
    

Reply With Quote
  #13  
Old June 20th, 2005, 08:48 AM
elijathegold's Avatar
elijathegold elijathegold is offline
Senior Fire Wizard
ASP Free God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2005
Location: Ashford, Kent. England
Posts: 5,651 elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4
Time spent in forums: 2 Months 2 Weeks 2 Days 4 h 37 m 4 sec
Reputation Power: 303
This seems to come up a lot, so is probably worth adding here.

If you are writing an sql query in asp and you are having problems with it, write it to the browser using

Code:
 response.write strQuery	'  or whatever your variable is called
 response.end
 


You can instantly see the entire query and perhaps the error in it. If it looks ok, copy and paste it into the database front end and run it there, you may get a better error message.

If it runs in the db, the quer is OK and the error lies elsewhere.
Comments on this post
BlueSkyRanger agrees: I use this technique, too. Very helpful!
__________________
And he picked it all up... in his pick-up.





Friends of Shemzilla

Reply With Quote
  #14  
Old June 20th, 2005, 09:48 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 49 m 54 sec
Reputation Power: 10
Of course, there is a MUCH easier way... provided that you have a good IDE.

"Step-through debugging"... just launch your ASP/ASP.NET app in Debug mode, attach to the process, then trigger a breakpoint and you can follow through each line, watch variables and params, etc...

Reply With Quote
  #15  
Old August 15th, 2005, 08:53 AM
elijathegold's Avatar
elijathegold elijathegold is offline
Senior Fire Wizard
ASP Free God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2005
Location: Ashford, Kent. England
Posts: 5,651 elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)elijathegold User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1989385 Folding Title: Super Ultimate Folder - Level 4
Time spent in forums: 2 Months 2 Weeks 2 Days 4 h 37 m 4 sec
Reputation Power: 303
This one works if you are prt of a team.

Get someone else to look at the code with you. When you are explaining how
the code works so they know what's going on, you will find the bug.

This sounds like a joke, but works well and it works because of the detail you
are having to explain the code in.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Debugging techniques


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek