Click here to Skip to main content
Click here to Skip to main content

Migrating website projects to web applications in VS2008

By , 28 Aug 2008
Rate this:
Please Sign up or sign in to vote.

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.

References

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:

Solution

I was searching upon some quick reference when upgrading things and this article is for those who want the steps to upgrading quickly.

Scope

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.

Migration

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
  • image001.jpg

  • You’ll be offered to upgrade the .NET version. For now, just click No to remain in version .NET 2.0.
  • image002.jpg

  • 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
  • File->New->Project
  • Select ASP.NET Web Application from the dialog box

image003.jpg

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.

image004.jpg

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.

The conversion

Now right click on the node in Solution Explorer and select Convert to Web Application.

image005.jpg

You’ll notice the change in Solution Explorer:

image006.jpg

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Muneeb R. Baig
Chief Technology Officer
Pakistan Pakistan
Just learning.
http://about.me/muneebrbaig
Follow on   Twitter   LinkedIn

Comments and Discussions

 
GeneralMy vote of 5 Pinmembergianerr19-Oct-10 23:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 28 Aug 2008
Article Copyright 2008 by Muneeb R. Baig
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid