I'm running in to a lot of inconsistencies with regards to what will compile and execute correctly in a Visual Web Developer 2008 Express environment and what fails on my web server.
In particular, I've got an aspx and aspx.cs codebehind, plus a number of additional .cs files in my Web Developer project. It builds fine and executes okay under the Development Server. Once I upload the files to my server, the codebehind doesn't seem to be aware of the other .cs files.
What's the correct way to make my aspx app inherit additional .cs files?
--- Update --- Since I'm not really finding the answer I need, let me be a little more explicit with what I'm doing:
I have three files:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Import Namespace="UtilClasses" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Default.aspx.cs
public partial class _Default : Page { }
App_Code/UtilClasses.cs
namespace UtilClasses {
public class AClass {
public const int A = 1;
}
}
In this example, if I attempt to do any of the following, I'll get a compilation error on my web server:
- Reference the App_Code with a @Import
- Call the code contained in it from the aspx.cs codebehind or
- Call the code from the aspx page.
It compiles fine in Web Developer 2008. The soltuion is a Web Site which is auto published to my web server via FTP. The exact list of files being published are:
- Default.aspx
- Default.aspx.cs
- App_Code/UtilClasses.cs
- web.config