title: Site using code behind files from the wrong directory?
body: <p>What settings in ASP.NET determine where (as in which directorie(s)) a website will look for its code-behind files?</p>
  
  <p>I have two versions of an asp.net c# website, Live and Dev.</p>
  
  <p>Live site: <b>www.example.com</b> with the pages and code in c:\dev\websites\examplecom_new</p>
  
  <p>Dev site: <b>d3.example.com</b> with the pages and code in c:\dev\websites\examplecom-d2</p>
  
  <p>There are historic reasons why the live site's directory ends in _new and why the dev site has d3 as its hostname and -d2 on its directory name, but they work and until now we've had no issues, developing things on d3 for subsequent release to live.</p>
  
  <p>I recently refreshed the dev site to be an exact copy of the live one (I usually do this before starting a new round of work), and started on some development work.  However, when I tried to run the code via the website, even though the browser was showing the Dev URL, d3.example.com, the error message referenced a code file from the live site's web directory, c:\dev\examplecom_new, not the development version c:\dev\examplecom-d2.</p>
  
  <p>I've gone through the code in detail to ensure there are no hard-coded references to either the www site or the path to the live site directory, and as far as I can tell there are none.  The code files in all cases are referred to in the .aspx files as local links, for example:</p>
  
  <pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/ExampleCom.master" AutoEventWireup="true"
      CodeFile="Checkout.aspx.cs" Inherits="Checkout" Title="Untitled Page" %&gt;
  </code></pre>
  
  <p>Yeah, I know "Untitled Page" isn't the most useful title in the world. :)</p>
  
  <p>I've gone through web.config, had a look in app_code\general.cs, and checked all the tabs on the Properties element in IIS, but I can't find anything that could be telling the site to use the .cs files from the live dir instead of the dev one.</p>
  
  <p>I tried restoring the previous (pre-refresh) version of the Dev site (I always back them up before replacing, just in case), just in case there was a config change I wasn't aware of, but the old version exhibits exactly the same problem, the Checkout page calls code from live, not dev, even though its URL is showing the dev verson in the browser.</p>
  
  <p>Needless to say this is something of a showstopper, the error that's happening appears to be due to a session mis-match between live and dev, but I have no idea why the dev site is calling code from the live site instead of code in its own directory.  Any pointers to what might be wrong would be appreciated.  I've tried both Googling for "asp.net code behind files called from wrong directory" and related searches, and searching Stack Overflow for the same types of thing, but not seen anything related.  We're not using pre-compiled binaries, just standard .aspx pages and .aspx.cs C# code files.  </p>
  
  <p>At first I'd assumed there must have been a hardcoded redirect kicking things over from dev to live, however I can see no trace of one and the browser address bar still shows d3.example.com/Checkout.aspx when I'd have expected a redirect to live to change it to the www version.</p>
  
  <p>The webserver is IIS 6 and we're running ASP 2.</p>