DCSIMG
Convert Visual studio Web site to VS Web Application project - Ran Wahle's blog

Ran Wahle's blog

Convert Visual studio Web site to VS Web Application project

Convert Visual studio Web
site to VS Web Application project

Asp.Net

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
model.

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.

7. Compile

8. Remove the old Web Site

Note: This post won’t apply for multiple programming languages web sites

kick it on DotNetKicks.com

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# February 23, 2011 3:29 PM

Vaishali said:

Hi .. thanks .. this post was helpful .. however my website has many many code files and I end up with many many class name collissions after the conversion (2553 collissions) ... now is there a way to automatically add namespaces to all my code files ... doing it manually is scary ... please help ...

# May 3, 2011 1:56 PM

Ran Wahle said:

Thanks for your question Vaishali.

The only thing I can suggest is to change the namespace of each class according to the folders the file is in, and change the code file class name to the page / user control name.

I'll soon write about changing namespace on web forms, so you'll have another thing to relate to, but no easy work guaranteed there...

# August 4, 2011 2:47 PM

Ran Wahle's blog said:

Changing namespace in ASP.NET Web-Form When converting VS Web-Site to VS Web application One of the problem

# August 4, 2011 3:24 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: