views:

123

answers:

2

I've recently inherited a fairly large web site. The project is set up as a web site in Visual studio, and not a Web Application. For a number of reasons, I would like to convert it to a web application.

I started converting the application using these directions from Scott Gu: Migrating a VS 2005 Web Site Project to VS 2005 Web Application Project.

While doing the conversion I discovered that this web site uses a ton of #include directives to include other .aspx files. The main problem with this is that currently each code-behind file directly calls controls (using this.) from the pages it is including.

This behavior seems to be allowed by the way that the compiler dynamically creates the .designer files in memory at compile time.

The problem is that since I'm converting the application to a Web Application, I'm creating physical versions of the .designer files. Now the same call to controls on the included pages (using this.), no longer work.

I've tried a few things to try and remedy this:

First, I noticed that the .aspx include files didn't have a @ Page directive, so I tried adding one. This prevented the app from compiling because the main page now had multiple @page directives.

Second, I tried to just rename the included .aspx files to .inc, but I still have the same problem of the main page no longer being able to access the controls as they could before.

Anyone ever done this before and have any thoughts on how to proceed without changing the entire structure of the web site?

edit: I decided not to go through with the conversion at this time simply because any benefits gained wouldn't be worth the trouble. Thanks for the help.

A: 

You'll need to refactor the #included content into classes and controls that can be used in the main pages.

ASP.Net will not do #include.

Joel Coehoorn
ASP.Net does do #include. Surprising and nearly forgotten about, but it's there.
martin
+1  A: 
  • You should convert included aspx files to classes, if they are used as code libraries in the old situation
  • You should convert aspx files, which contain html, server- and/or HTML-controls to usercontrols (ascx files)

This should be a good starter for now. Later on you could refactor to your own taste.

Hope it helps.

norbertB