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 see
There's a lot of conflicting information here. For example, if you are truly creating an ASP.NET Web Application (as opposed to a web site), then you should not be using CodeFile
, as used2could suggests.
Have you tried checking the Build Action of your code-behind files? Make sure it is set to Compile.
I think we need to start you from scratch, to identify if the problem is coming from your web project, your IIS configuration, or both.
I'm going to make the following assumptions about your set up, because this is my current set up. Let me know if any of these are wrong, but it shouldn't make a huge difference:
Let's try to keep this as simple as possible, to minimize any chance of weirdness:
Contents of Default.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/SiteLayout.Master"
AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="TestWebApp1.Default" %>
This is a test
Contents of Default.aspx.cs:
using System;
namespace TestWebApp1
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblTest.Text = "Modified from Default.aspx's Page_Load method.";
}
}
}
Contents of SiteLayout.Master:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="SiteLayout.master.cs"
Inherits="TestWebApp1.SiteLayout" %>
Contents of SiteLayout.Master.cs:
using System;
namespace TestWebApp1
{
public partial class SiteLayout : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
lblTest.Text = "Modified from master page's Page_Load method.";
}
}
}
Now, this site should work without fail when debugging in your local computer:
After following the above steps, are you still getting problems?