Monday, March 17, 2008

Enable Edit and Continue in VS2005 Web Application Project

You must have used to keeping your project debugging while you write code. This is for sure because of the timeconsuming build that you could afford just once a day. But now with using web application project this is a bit different. First, it builds faster, second, you can enable edit and continue mode. This is how to do that:

1. Go to project Properties, tab Web. Check Enable and Continue. Note that this is available only when debugging in local VS dev server, but not IIS web server.

2. Go to Tools/Options/Debugging/General and check Break all processes when one process breaks.

3. Make sure you start your project in Debug mode.

4. Set a breakpoint in the page that you would like to edit. When the process stops at this breakpoint, you can edit this page (and only this page!)

See more about web application project and edit and continue
here.

Migrating to VS2005 Web Application Project Problems

When I was trying to migrate to my VS2005 Web Site Project to VS2005 Web Application Project, I had a weird problem. I had one user control that uses asp.net ajax and a page that uses this control. While the control itself succeeded in Converto To Web Application operation (from the context menu of the project), the page did not. What solved the problem was adding a Register directive to the page (just for generating the designer file) and removing it after that:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

Another thing that took me some time was that I had to change manually the Build Action for all my files from App_Code from Content to Compile.

More for migrating from vs2005 web site project to vs2005 web app project can find here. If you want to migrate vs2003 web project to vs2005 web app project, see here.

How to Access UserControl from shared code in VS2005?

If you use the standard model - web site with App_Code directory, you could access a UserControl if you implement an interface that also belongs to App_Code. This is because asp.net compiles App_Code in one assembly, and the other folders (or every single page/control) in other assemblies. Other ugly way to do this is by using reflection, which I do not recommend. The best way is to migrate to Web Application Project which is very similar to the old good time of VS2003 projects that we all are used to. This goes with service pack 1 of the studio. You get a single assembly and thus all your pages and controls are visible to your utils classes.
eXTReMe Tracker