Asp debugging with VS

The so-called dynamic debugging (trace) refers to let the program step by step execution, program running state concern us anytime, anywhere. Interrupt means is to let the program do not rush to execute down, and so I look over, and then went running to give you instructions. Breakpoint What is the point of interruption chant, is to run the program at this time, to break down, stopped Let me see :)

1. To use vs to debug, first let enable server-side debugging, is to set it in iis on the line, iis7 set as illustrated (iis7 not only the site that you want to set, also set to take effect in IE that):



2. in IE's Internet options -> settings -> advanced debugging is disabled (canceled tick) -> show Friendly Http error Messages (tick canceled)



3. in the place you want to debug, insert stop statement:



4. page ie access will pop up dialog box, select vs2005 or vs2010 as a debugger, all right, and click "Yes" (VS2010 exit point when seemingly there is a problem)



After that, there will be additional security warning, it does not matter, you can choose to attach to this process, that is, click "add." It will come out debugging interface:

Attention four places:



The top debug toolbar, command buttons that have to track debugging.

The leftmost column of the yellow arrow and the gray, yellow arrow tells us now to run to that step.

The right Solution Explorer is loaded asp iis server files.

The bottom bar some tips or helpful, such as the call stack, local variables, monitoring and so on.

Now combine debugging instance, one by one interpretation for everyone.

We must first understand the debug toolbar, to introduce several commonly used:



Click the green triangle allow the program to continue, if there is a breakpoint back (behind describes how to set breakpoints) will interrupt or stop it, otherwise the server asp in the footsteps finished, you can see the results on the page. The third blue box button, refers to the end of commissioning, even if there is a breakpoint will not be interrupted. The yellow arrow is used to display the current interrupt position, we could look at the code on other pages, forget where the current program running, click on the yellow arrow can immediately go running point (yellow arrow position indicates that the statement has not been executed ).

Then the next three buttons are tracking way (to understand its meaning), the first (shortcut key f11, that is, from left to right in the sixth) refers to single-step through the code, if you encounter a function call (to write their own ), also single step inside. The second (shortcut key f10) buttons also step through the code, but encountered the function call will not be executed inside (that is, the assignment statement, or no function calls, the same role of f10 and f11) . The third (shortcut shift + f11) button is also a quick return, that is when we trace to a function where by f11, press the button, it will complete the implementation of the function, and return to the next sentence calling function.



For example, the server is ready to perform Easp.Use "tpl" This statement, if I press f10, then the yellow arrow to move to the next statement: Easp.Tpl.Load "test.html". If f11 are tracked by Easp.Use to this function, as shown below:



For Use our little doubt, do not want to Use function inside tracked step by step, you can press shift + f11 (click on the toolbar button is also OK J) will jump Use function, the program will be in Easp.Tpl.Load "test.html "interrupted at the statement.

In the process of tracking, you may encounter a loop, if the cycle is hundreds of times, but also tracking down step by step, then not wearing them. Of course, before you can debug, and wrote at the end of a cycle stop statement, click on the green triangle to skip cycle. However, if the start did not expect it? It will not end up never :(. This time we can use the break function! Is like setting breakpoints dynamically inserted statement when we stop in tracking method is very simple, in the statement where you want to break in, right-click and select breakpoint -> insert breakpoint this is, will be more of a small red dot in the gray column, it means the break point.





In this case represents Easp.W Easp.Tpl.GetHtml set a breakpoint, when the program will stop here to run down.

Just generally tell you how to use the stop statement to activate vs debug, then, how to set a breakpoint in the debugging process, and step by step tracking, if the tracking function, and how quickly jumped out from the function . However, we debugging purpose is to find out the bug, the key point is to see the value of a variable, then we take a look at a static debugging, write a bunch of stuff to see, but not at the cost of dynamic debugging Chuihuizhili can get.

The easiest is to click the bottom of the "local"



all current variables can see, and the type of value of the variable, the variable is also clear. Click the plus sign corresponds to an object variable can expand to view a lot of information.


Oh, do not write any statement you can see: When visiting the page, there is a get argument, "id = 123", see the session ah, application ah very convenient, their own definition of the variable is not to say, of course, if the program is not to run at variable assignment, there would be nothing oh. Even the record set view is also very convenient.

Because it is interrupted in asp page, you are able to see a lot of global variables and functions to enter, click on the "local" would really only monitor the function of the variables. Wherein, Me refers to the object itself, somewhat like this pointer in the object-oriented language.



Oh, in fact, do not worry, click on the "watch" in the Name column, enter the variable name you want to know, and then press Enter, you can! And in the inside of the input dynamic calculation no problem!



Such debugging is not more convenient than a trace of some? To test the value of the variable not to write a bunch of code, but look at the program logic appears n times feel when error-free, just do not know what the variable is in error, with dynamic tracking very simple. There are many more features, not introduced, we studied the results of contribution remember Oh!

Hee hee, in fact, can use VS to write asp website, so writing and debugging is fully integrated with the debugger stop do not have to write :), but also integrated vs vss, svn source code management tools, such as the development team also very convenient. All in all, a lot of advantages vs to write ah (hey, Microsoft's IDE is too toxic!), Just not the kind of DW on intelligence tips Easp (but prompted vbscript), but after writing that a few cooked Easp function also can not remember?


PS: previously written a blog in another article ~

Reproduced in: https: //my.oschina.net/iwuyang/blog/198631

Guess you like

Origin blog.csdn.net/weixin_33909059/article/details/91897373