This tip was submitted to the Visual Studio .NET Info Center Tip Exchange by member John Sorensen. Let other users know how useful it is by rating the tip below. Got a tip or code of your own you'd like to share? Submit it here.
System testing and debugging on our large ASP.NET project was taking too long. For every test, we needed to compile, load and authenticate. We were spending more time loading, navigating and authenticating than we were spending testing and debugging -- until we found a useful shortcut.
I am working on a large ASP.NET project where we are using Microsoft Passport authentication. We have completed unit testing, so we have started system testing. Every time I want to perform a test, I have to authenticate with Passport to get to the site.
This is what I have to do: Go to the IDE. Then hit the Start project button in the tool bar (F5), which builds and starts the project. Next, I have to wait for the project to load. I then have to log into Passport (which takes a long time since I am hitting the development servers), and then I have to navigate to the page I want to look at (which takes more time -- even longer depending on which portion of the site I am working on). Then I have to test my code. If I didn't quite get the code correct, then I have to stop the IDE, correct the code and do it all over again. This is a very time consuming process.
Here is a feature of Visual Studio .NET that saves me from having to wait for the IDE to load, log into passport, wait for the development Passport servers to authenticate me and then navigate to the correct section of the Web site before I can do my test.
- Open up a browser. (Let's call it "A.") Go to the section that you are interested in viewing ("http://localhost/Subsection/ObscurePage.aspx" for example).
- When you hit the "Debug -> Start" (F5 shortcut key) in the IDE, another browser (let's call it "B") opens up.
- In the IDE, place a break point some where in the "ObscurePage.aspx.vb."
- Now, in Browser "A, initiate an event that will reload the page (a button click, or just reload the page). Browser "A" will then go into debug mode even though Browser "B" is the browser that was associated with the debugging session.
- Step through the code.
If you discover that you need to make a change to the code, step all the way through the code so that Browser "A" is no longer attached to the debugger. Click on the "Stop" button in the IDE toolbar (Debug -> Stop Debugging or Shift+F5). Browser "B" will close. Make your change to the code. Rebuild the project (Build -> Build Solution or Ctrl+Shift+B). Hit Refresh in "Browser A", and you will see the new code that you just worked on displayed in Browser A. If you need to step trough the code again, repeat steps 2 - 5 above.
I have done this same process when using Terminal Services to log into a remote machine and execute code on my local machine. In this case, Browser "A" was on a different machine, but using steps 1 - 5, I could step through the code locally. I have done this where Browser "A" is a version of Internet Explorer or a version of Netscape. This has been a huge time saver.