Convert Visual studio Web site to VS Web Application project
Convert Visual studio Web
site to VS Web Application project
At the customer I work for there are several
applications written as a web site instead of
Asp.Net web application project . The
reason for that is rather old, they’ve used
Visual Studio .Net 2005 before it’s service pack 1
were released, and Asp.Net web application project wasn’t
offered as a project template.
If you need to choose between the two development models, you might want to read this post. However, today most development teams I’ve encountered, doesn’t use the web site
In this post I’m going to demonstrate, in a few steps, hoe to successfully convert
VS-Web Site to VS-Web Application Project.
So, when encounter a VS-web site, how can you convert it?
1. Open new web application project (an empty one if you’re using VS-2010). Unfortunately you cannot convert the web site within itself.
2. Copy the entire project content to the new project.
Do so by marking all root files and folders on the web site (all but Bin and Obj
folders), right click and choose copy from the context menu, go to the new project,
right click and choose paste.
3. Copy references:
For each .dll file in the Bin folder, you should add it as a reference. That’s actually the hardest part in the process because you need to track all sources. The
references can be found on the web site’s property pages, on the references tab.
4.Make sure all code files are compiled:
For all code files (most of them you may find on App_Code folder), make sure that their build action is “Compile”. You may find their build action to be “Content” and then you have to change it.
Note: If for some reason your code doesn’t compile because some code-behind doesn’t know classes within the project, you may have skipped step 4
5. Namespace – Make sure all code files has namespace. Web-Site doesn’t provide
namespace by default, so after copy your code files you should do so.
6. Convert to Web Application:
By right clicking your project and choose “Convert to web application” you will add for each markup file (ASPX, ASCX) a .designer.cs (or designer.vb) file which exists on Web Application Project but doesn’t exist on Web Site.
8. Remove the old Web Site
Note: This post won’t apply for multiple programming languages web sites