Introduction and problem statement
I had created our website using VS2005. As you are aware, VS2005 handles website solutions a bit differently, since it doesn’t have project files
for websites. Everything that is in the folder is included in the build/site, unless otherwise excluded.
The Web Application feature is now back in VS2008. This article will help you upgrade your website projects created in VS2005 to web application projects
in VS2008. You might need this in order to get full benefit of the new features of VS2008 or you might be upgrading your site to the later versions of .NET (3.0 or higher).
You can have a look at the following articles that detail about the enhancements in VS2008:
I was searching upon some quick reference when upgrading things and this article is for those who want the steps to upgrading quickly.
As the title suggests, we are upgrading our website developed using VS2005 over .NET 2.0 to VS2008 while keeping the .NET version.
Before you begin
Make sure you have the latest code in hand and compiled without errors. Preferably make a new folder and copy the code to the new location.
Step 1: Upgrading website to VS2008
- Launch 2008
- Select File->Open->Web Site
- Navigate to the newly created folder or the folder where the website code resides, select it, and then push the Open button
- You’ll be offered to upgrade the .NET version. For now, just click No to remain in version .NET 2.0.
- Compile and make sure that your website is running perfectly. You might need to set some references, for example, references to AJAX libraries.
Step 2: Changing a website project to a web application
The easiest way to migrate is to create a new solution/project and copy the site to it or add a new web application project to the one we created in the previous steps:
- Launch VS2008
- Select ASP.NET Web Application from the dialog box
However, if you want to add a VS2008 Web Application project to an existing solution, right click on the solution node and select Add->New Project.
After the creation of the VS2008 Web Application project, remove the "default.aspx" and "web.config" files by deleting them; these files are added
by the wizard by default. This is because you’ll be using your own files.
If you’ve created a new project, open the website in the same solution: File->Add->Existing Website.
Moving the files
Now with both the web application and the website open in Visual Studio, select all the files and folders in the website and drag and drop them to the web application.
If the Data Source Configuration Wizard is launched during the process, cancel the dialog and allow the rest of the files to be dropped.
Now add references to your newly created web application, and remove the website from the solution.
Idea behind conversion
The main difference in website projects and web applications is that website projects dynamically generate the tool-generated partial classes of a page,
and do not persist them on disk. Web Applications on the other-hand do save these partial classes on disk within files that have a .designer.cs extension and compile
them using the in-memory VS compilers when a build occurs.
Now right click on the node in Solution Explorer and select Convert to Web Application.
You’ll notice the change in Solution Explorer:
The designer.cs files are added to the pages.
Where is my App_Code folder?
ASP.NET 2.0 dynamically compiles classes under the App_Code folder. Keeping your classes under this folder will get the classes compiled twice;
resulting in a "could not load type" runtime exception -- caused because the type names are duplicated in the application. I recommend using
the Classes folder to store your classes; however, the "Convert to Web Application" command would rename the folder to Old_App_Code.
Compile and Run
You’re almost finished, just compile and run the site to make sure that you’ve successfully migrated your website project to a web application project.