title: None of my "code behind" code is being called
body: <p>I have just created an ASP.NET C# project and a virtual directory for it in IIS in (as far as I know) the normal way, but I am seeing very strange behavior that I have never seen before.</p>
  
  <p>It seems that <strong>none</strong> of my C# methods are ever being called.  I know this because I have overridden a bunch of methods to do nothing but throw an exception.  At least Default.aspx is viewable in the browser (see below)</p>
  
  <p>Here is the exact content of my Default.aspx.cs file:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  namespace Drawings2
  {
      public partial class _Default : System.Web.UI.Page
      {
          static _Default()
          {
              throw new Exception("XXX");
          }
          public _Default()
          {
              throw new Exception("XXX");
          }
          override protected void OnInit(EventArgs e)
          {
              /*
               * base.OnInit(e);
               * InitializeComponent();
               */
              throw new Exception("XXX");
          }
          private void InitializeComponent()
          {
              /*
               * Load += new EventHandler(this.Page_Load);
               */
              throw new Exception("XXX");
          }
          protected void Page_Load(object sender, EventArgs e)
          {
              throw new Exception("XXX");
          }
      }
  
  }
  </code></pre>
  
  <p>I assume this code is not being loaded at all, because if it was then I would see an exception whenever I tried to view the page in the browser.  Instead the content from the .aspx file appears normally (except that my event handlers are not called.)</p>
  
  <p>It gets worse when I try to add new .aspx pages.  I get this error when I try to view a new page in the browser (this is with the unmodified .cs file from the VS2008 template):
  Parser Error</p>
  
  <pre><code>Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 
  
  Parser Error Message: Could not load type 'Drawings2.WebForm1'.
  </code></pre>
  
  <p>What can cause an ASP.NET site to get into this strange state?</p>
  
  <p>Note: <code>&lt;%...%&gt;</code> escapes in the .aspx file still work fine.  Also when I add form fields in the .aspx file, I can auto-complete their names in the .cs file.  I have tried both <code>true</code> and <code>false</code> for <code>AutoEventWireup</code> on both pages.  I have also tried adding and removing "partial" from all class declarations.</p>
  
  <hr>
  
  <p><strong>Update</strong> - here are my @Page tags.  As I said, I have tried toggling <code>AutoEventWireup</code>.  The referenced <code>.cs</code> files exist and compile with no errors.</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="Drawings2._Default" %&gt;
  
  &lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Drawings2.WebForm1" %&gt;
  </code></pre>
  
  <hr>
  
  <p>Related:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/73022/codefile-vs-codebehind">CodeFile vs CodeBehind</a></li>
  <li><a href="https://stackoverflow.com/questions/2098146/asp-net-code-behind-or-no-code-behind">ASP.NET: Code behind or no code behind?</a></li>
  </ul>