5,699,997 members and growing! (22,483 online)
Email Password   helpLost your password?
Web Development » ASP.NET » Howto     Beginner License: The Code Project Open License (CPOL)

Migrating website projects to web applications in VS2008

By Muneeb R. Baig

Step by step explanation to migrate website projects to web applications in VS2008
C# (C# 2.0, C#), ASP.NET, Visual Studio (Visual Studio, VS2008), Dev

Posted: 28 Aug 2008
Updated: 28 Aug 2008
Views: 4,022
Bookmarked: 14 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
2 votes for this Article.
Popularity: 0.54 Rating: 1.80 out of 5
1 vote, 50.0%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
0 votes, 0.0%
4
1 vote, 50.0%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction and problem statement

Earlier I created our website using VS2005. As you are aware that VS2005 handled 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 upgrading your website projects created in VS2005 to the 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 upon the following articles that detail about the enhancements in VS2008:

http://msdn.microsoft.com/en-us/library/bb386063.aspx

http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx

Solution

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

Scope

As the title suggests, we are upgrading our website developed using VS2005 over .Net 2.0 and will be upgraded 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 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

<formulas /></formulas />

image001.jpg

  • You’ll be offered to upgrade the .Net Version. For now just click No to remain the version to .Net 2.0.

image002.jpg

  • Compile and make sure that your website is running perfectly. You might need to set some references for example you need to set reference to AJAX libraries.

Step 2: Changing website project to 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 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 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 the 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 half of a page, and do not persist them on disk. The 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 the solution explorer and select Convert to Web Application.

image005.jpg

You’ll notice the change in the 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 "could not load type" runtime exception -- caused because the type names are duplicated in the application. I recommend using 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 you website project to the 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


Just learning.
http://muneebbaig.blogspot.com/
Occupation: Architect
Location: United Arab Emirates United Arab Emirates

Other popular ASP.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 28 Aug 2008
Editor:
Copyright 2008 by Muneeb R. Baig
Everything else Copyright © CodeProject, 1999-2008
Web10 | Advertise on the Code Project