Tuesday, January 10, 2012

Adding files from an ASP.Net Web Site to an ASP.Net Web Application

If you have ever worked with both ASP.Net Web Sites and ASP.Net Web Applications, you will probably have noticed that the biggest difference between the Web Site and Web Application projects is that the Web Application projects also include a .aspx.designer.cs file.

Unfortunately, if you add a file from an ASP.Net Web Site project to an ASP.Net Web Application project, that file is not automatically added for you.  In addition, the Web Application project will not even compile if that .aspx.designer.cs file is not present!

Fortunately, though, there is a workaround to allow your ASP.Net Web Application projects to compile successfully.


  1. Add your ASP.Net Web Site files as usual to your ASP.Net Web Application project
  2. Right click on your ASP.Net Web Application project and select "Convert to Web Application"
  3. When prompted with a dialog stating that the files will add the necessary designer and code behind files, click Yes.
  4. This will now add the necessary files that were previously missing to the ASP.Net Web Site files.
  5. Attempt to re-compile your application now.  
  6. Your project should either successfully compile or at least compile with fewer "designer-related error messages"


No comments:

Post a Comment