Convert Web-site to Web Application.

Discussion in 'ASP .Net' started by mark4asp, Jul 1, 2009.

  1. mark4asp

    mark4asp Guest

    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.
    mark4asp, Jul 1, 2009
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sean
  2. mike kim
    Aug 20, 2003
  3. Tiddley-Pom
    Mark Parnell
    Oct 15, 2003
  4. David Lozzi
  5. mark4asp
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Mar 24, 2007
  6. Lloyd Sheen
    Lloyd Sheen
    Nov 15, 2007
  7. Samuel R. Neff
    Samuel R. Neff
    Jan 2, 2008
  8. John A Grandy

    convert web site to web app

    John A Grandy, Jan 26, 2009, in forum: ASP .Net
    Cowboy \(Gregory A Beamer\)
    Jan 26, 2009