posted on Wednesday, April 27, 2005 9:50 AM
by
anoras
Edit and Continue in ASP.NET 1.x
Steve Cellius, CTO at BV Networks, showed off his developer's toolbox on the April Norwegian .NET User Group (NNUG) meeting. The slide deck is available for download here (registration required).
Steve's session wasn't all about tools, he also did gave some tips on how to use Visual Studio .NET more efficiently. One of the things he demoed was how to attach to the ASP.NET worker process to debug web applications instead of starting the application in debug mode.
This tip reminded me of a "secret feature" in Visual Studio .NET which most developers aren't aware of: edit and continue for ASP.NET applications.
ASP.NET monitors the application for changes in files and does necessary updates if a change occurs. You can exploit this feature to make ASP.NET compile your code files whenever a change is detected in them. If you add an ASPX page the virtual folder and make its src attribute point to a source file, this file will be compiled when ASP.NET detects that it has changed. Only one src attribute is allowed per page, so you might have to add some dummy pages to your project if you have business entities or other classes in your web project.
If you use src attributes instead of precompiled code behind classes, you can edit and continue when you stumble across an error while debugging your application. To do this, just choose "Detach All" from the "Debug" menu. Then edit your code and save the file. ASP.NET will detect that the file changed and recompile it. To continue debugging select "Processes" from the "Debug" menu and check the "Show system processes" and select the ASP.NET worker process from the list and attach to the process. On Windows XP this process is named ASPNET_WP.exe, on Windows Server 2003 it is named W3WP.exe. When you refresh the browser, you'll hit the breakpoint with you new bug free code running.
If using src attributes to trick ASP.NET into compiling your code isn't really your cup of tea, you can still enjoy the benefits of edit and continue, but you'll have to build the solution yourself before you continue.
Everyone knows that Visual Studio .NET 2005 has proper edit and continue support. Still it many developers will be stuck working on ASP.NET 1.x projects for some time. If you are one of those developers, the poor mans edit and continue feature will probably make waiting for ASP.NET 2.0 projects easier. At least you'll save some time not having to start and stop the debugger all the time.