I wanted to save this tip for later but I think it's too important to hold back. The one action of attaching to a process will save you minutes, that's right MINUTES, in your daily tasks.
You might have noticed in my last post about Keyboard Shortcuts I never mentioned the F5 key. That's because I never use it.
The F5 key is commonly used to "Start Debugging." Let's take a moment to walk thru what happens when you press F5. (Or click the green play button, or thru the menu Debug > Start Debugging)
The F5 Way
- First, Visual Studio (VS) will build your startup project.
- Second, VS opens an instance of your configured browser and attaches to the browser's process.
- Third, VS will direct the browser to the start page of your start-up project.
- Forth, VS finally attaches to the process hosting ASP.NET
- w3wp.exe if you use IIS6
- aspnetwp.exe if you used IIS 5.5
- WebDev.WebServer.exe if you use the ASP.NET Development Server that comes with Visual Studio.
Now, lets assume you want to debug some new administrative feature you've added to your web application. After all of the "F5" steps, most likely you:
- Fifth, start on your start page (I'll assume Default.aspx)
- Sixth, click on the Login link
- Seventh, login with Username and Password
- Eighth, browse to the Administration page with the feature you want to test
Now, lets assume you have a bug in your code. Your next step might be:
- Ninth, close the browser
- Tenth, change the code to fix the bug
- Goto First
The "Attach to Process..." Way
So, how can "Attach to process... " save you minutes? By not repeating the Second, Third, Fifth, Sixth, Seventh, Eighth, and Ninth steps from above.
Here is the process I use:
Once per day:
- Open Browser
- Browse to development website
- If Root: (http://localhost)
- If Virtual Directory: (http://localhost/vDirectory)
- Click Login link
- Login with Username and Password
- Browse to the Administration page where the new feature will be
That's right, I usually only do these 5 steps once a day.
Now, I write my new administrative feature. Then, it comes time to test my changes.
<note>
This is where my first three common "walks" of my last post become important.
</note>
- First, build the current web project if needed.
- (Alt, B, U)
- Second, attach to process hosting ASP.NET.
- w3wp.exe (Alt, D, P, W 3, Enter)
- aspnetwp.exe (Alt, D, P, A S P, Enter)
- WebDev.WebServer.exe (Alt, D, P, W E B, Enter)
- Third, switch to the open browser
- (Alt+Tab)
- Fourth, refresh page as appropriate
- (F5 or Ctrl+F5 or Alt+D, Enter)
Lets assume there is a bug in my new code. (I know it's hard to believe, but just for giggles lets assume.)
- Fifth, detach from the process hosting ASP.NET
- (Alt, D, D, [sometimes Enter])
- Sixth, change the code to fix the bug
- Goto First
Conclusion
By using "Attach to Process..." we save ourselves repeatedly launching and closing the browser, the login process, and the preliminary navigational steps to get to the code we want to test. These actions which took minutes and were repeated with every "F5" now are only done once.
Great tip, Justin! I only learned about Attach to Process two years ago. I can honestly say that in the two years since I've only used the F5 way a couple of times - and I think those were when I was working on a console app or a web form. For an ASP.NET developer, who always has his project open in a browser, it is much easier to use Attach to Process.
ReplyDeleteNice post...
ReplyDeleteThis information about asp.Net development tips with attachment is very nice and useful for users and developers. Thanks for sharing.
ReplyDelete