Josh Campbell
Josh Campbell

Reputation: 458

Convert ASP.NET Web Application to ASP.NET WebSite

SCENARIO: A developer at work has created an three-tier ASP.NET Web Application which plugs into the company website, however the rest of the site was done as an ASP.NET Website. For clearity, his portion used Web Application (compiled into single .dll) and the rest of the site is WebSite (seperate .dlls). I do not wish to recompile the website every time a change is made to a page.

QUESTION: Is it possible to convert a Web Application to a Website without rewriting the entire application?

TRIED:

  1. Created WebSite and copied & pasted files over
  2. Changed'CodeBehind' to 'CodeFile'
  3. Deleted .designer.cs from pages and controls
  4. Checked References

Upvotes: 2

Views: 4249

Answers (1)

Mark Brackett
Mark Brackett

Reputation: 85625

Ok - assuming you have a backup, this is how I would tackle it:

  1. Delete the csproj file
  2. From within Windows Explorer, delete any designer.cs files
  3. Still in Explorer, create an App_Code folder at the root of the site
  4. Find any *.cs files that aren't code behinds (eg., .ascx.cs or .aspx.cs) and move them into the App_Code folder
  5. Open in Visual Studio as Web Site project
  6. Verify .NET FX version
  7. Change CodeBehind= to CodeFile= in any .aspx or .ascx files
  8. Readd any 3rd party references

There's some potential complications around Global.asax, ASHX handlers (need to be inline) and referencing pages and controls. You'll have to deal with those manually, I'm afraid - but if it's a smallish effort, it should be easily doable.

Upvotes: 7

Related Questions