How to reference the same CodeBehind class from multiple .aspx files (and be able to pre-compile the

Posted by thelsdj on Stack Overflow See other posts from Stack Overflow or by thelsdj
Published on 2010-04-09T03:48:12Z Indexed on 2010/04/09 3:53 UTC
Read the original article Hit count: 316

I have a set of aspx pages that each live in their own directory and reference a single aspx.cs code behind file.

This has worked fine previously because I never tried to pre-compile the site. IIS must have individually compiled each aspx, linking them to the contents of App_Code but never referencing more than one aspx at a time.

Now that I'm trying to pre-compile the website using Web Deployment Projects I keep getting errors about the same class being found in multiple assemblies.

I can't just drop the aspx.cs in App_Code and subclass it because it wouldn't be able to find the controls on the .aspx pages when compiling. Maybe I could explicitly define every control on the page in the .cs? But would that allow them to be wired up correctly?

Any other ideas on how I can reference the same Page class from multiple .aspx pages and be able to pre-compile the entire website?

© Stack Overflow or respective owner

Related posts about asp.net-2.0

Related posts about web-deployment-project