views:

55

answers:

2

If you started developing as a project, how difficult is it to migrate into a web site development process?

+1  A: 

Migrating a web app project to a web site isn't that hard, really, but can have a few gotchas. Be advised, however, that web site projects have distinct disadvantages. Their bin folders are messy, code reuse is more difficult except for the disciplined software architect, web sites cannot use MSBuild pre- and post-build events, etc.

Some things to consider when converting a site:

  • Create a new web site in a different folder and copy relevant files to it. It is not practical for a web app project and a web site to coexist.
  • Web sites don't use the .designer.cs file for user controls, master pages, and pages, so you can nuke them.
  • All non-code-behind code must be moved to the App_Code folder or a referenced library to be generally accessible to all pages.
  • Web service code-behinds must be moved to the App_Code folder.
  • Service references should be deleted and re-built.
  • Re-add references to the web site as you would do for a web application project.
  • It is not strictly necessary to declare namespaces for code-behind classes anymore, but it is also not strictly necessary to remove existing namespace declarations.

The gotcha most likely to bite:

  • Pages no longer are aware of each other's code. In a Web App project, all code is in one assembly, and is therefore easier to share. In a web site, there exists one assembly per directory/sub-directory.
kbrimington
A: 

I would like to add to the steps given here. In Web application all code behind to into one dll where was Web sites have separate dll for each page or folder, hence there is no inherits tag in the aspx page for Web application project, remove all inherits tags and place codefile=".....aspx.cs" in the Page directive. While you publish or precompile the website these inherits="....aspx.cs" gets replaced by compiled page type in the page dll.

Kiran Bheemarti