Attach to Visual Studio's Development Web Server easily using a macro
Unfortunately, there is no easy way to do this from Visual Studio. We have to attach to the server process "by hand". After some time doing this, you'll find it a bit boring...
Here is a quick-n-dirty solution. It's a simple macro that attaches to the first web server process it finds. Just copy the code below to your macros using the Macro IDE (Tools | Macros | Macro IDE...).
Once you have the macro, you can:
- add a button to a toolbar by right-clicking on the toolbars, then "Customize... | Commands | Macros" and drag & drop the command on the toolbar of your choice
- map a shortcut key to it using "Tools | Options | Environment | Keyboard" and search for the AttachToFirstDevWebServer
Warning 2: the code searches for Visual Studio 2005's integrated Development Web Server. To attach to IIS instead (from VS 2003 for example), you'll have to adapt the code to attach to aspnet_wp.exe.
' This subroutine attaches to the first Development Web Server found.
Public Sub AttachToFirstDevWebServer()
Dim process As EnvDTE.Process
For Each process In DTE.Debugger.LocalProcesses
If (Path.GetFileName(process.Name).ToLower() = "webdev.webserver.exe") Then
process.Attach()
Exit Sub
End If
Next
MsgBox("No ASP.NET Development Server found")
End Sub
Update: you may have to replace "webdev.webserver.exe" by "webdev.webserver2.exe"