Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Convert Web-site to Web Application.

Thread Tools

Convert Web-site to Web Application.

Posts: n/a
Some notes to jog my memory in case I have to do this evil time-wasting
thing again.

This was using VS2008 with Asp.Net 3.5 websites.


You need to do this as a first step to make parts of the web project


1. Ensure that the website uses just two namespaces
(this worked for me!).

I put all web pages in one namespace and all App_Code stuff
in a 2nd namespace. I also moved all the code in App_Code to
the root of App_Code.

2. Ensure that every bit of code is in a namespace.

[NotePad++ is excellent for adding and modifying stuff like this
because it has search and replace supporting both regular expressions
and 'replace in files']

3. Build and check that it works [The website after these edits].

4. Create a new Web App Project.

5. Delete web.config and Default.aspx

6. Add any binaries to /Bin

7. Add any references used by the website

8. Build the project!

9. Copy relevant files over from the website to the web app. [Do not
over-write the /properties, /bin, etc.]. Any web references (e.g. to
external web services) will need to be recreated.

10. From solution explorer, with the root of the project selected,
apply the command Convert to web application.

11. When it fails!, identify the problem and remove it by fixing the
problem in the website [compiling and testing the website make sure it
works]. The most likely cause of failure is a broken server control.
This will need to be rewritten first or entirely removed (and added
back later).

12. IMPORTANT. If the conversion got as far are renaming /App_Code as
/Old_App_Code then one can proceed otherwise stop, delete the entire
web application project and start again! - it's pointless continuing
otherwise because you will just waste your time attempting to
understand meaningless compiler error messages. If the App_Code can't
be seen despite using clauses referencing it then the entire project is
junk and should be ditched.

I had to attempt the conversion 4 times before it finally worked - each
time collecting a new clue regarding what was wrong and fixing the
problem in the website before continuing with the next attempt.

By next attempt I mean deleting the entire failed web application and
starting from scratch.

13. The final part just involves fixing a few pages which failed to
convert because they were using a dodgy control. After removing the
control from the page, click on the page and apply "Convert to web
application" to that page. Do this for every broken page or
UserControl. The control will need to be fixed and added later. Add it
to your to do list.

14. A few namespace changes may be needed here but before continuing
ensure that it now builds and works.

15. Global.aspx and web services may be tricky.

15. All the App_Code can now be moved to a new project in the same
solution. Each page will then need a reference to the new project (as
will the web application itself).

16. Procede stepwise, removing code to new projects, adding references
and namespaces. I had to create a new web service project, data
project, model project (containing no depencies at all) and finally a
business project. Moving relevant code from /Old_App_Code to them,
adding references and using clauses as they were created, building the
solution after adding each new project. NotePad++ comes in really handy
here for the namespace changes.

17. Now I just need to fix the broken server control and add it back to
the pages I deleted if from then it will be fine and dandy again - and
testable at last. Oh and I just need to write the tests.

This was such a pain for me to do and I wasted so much time trying to
proceed manually after failure to (a) sort out namespaces beforehand
and (b) attempting to manually fix it after the conversion wizard gave
up before the /Old_App_Code folder was created. Remember to give up at
this point and try the conversion from the beginning again.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Convert to Web Application" didn't convert pages to partial classes in 1.1 -> 3.5 migration Samuel R. Neff ASP .Net 0 01-02-2008 03:38 PM
IsNumeric: Convert.ToInt32 vs. Convert.ToInt64 sck10 ASP .Net 4 09-03-2006 09:40 PM
To convert to J2SE 6 or not to convert, that is the question... Jaap Java 4 07-10-2006 09:03 AM
convert list of strings to set of regexes; convert list of strings to trie Klaus Neuner Python 7 07-26-2004 07:25 AM
Do I need to Convert with Convert.ToInt32(session("myNumber")) ? Andreas Klemt ASP .Net 1 07-23-2003 02:59 PM