The file 'Default.aspx.cs' does not exist.

In an ASP.NET project, when you compile your project it shows message "Rebuild Succeeded".

As soon as you run your project you may encounter and error message that says
The file 'Default.aspx.cs' does not exist.
How is it possible, your compilation was successfull and a .cs file is missing :)
Below is the solution that you can look into:

Open your Default.aspx file in HTML source, and check the Page directive

<%@ Page Theme="Default" Language="C#" MasterPageFile="~/HomeMaster.master"  AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="MyWebapplication.Default" %>

If you can see the CodeFile property here, that's the cause of error. Just change "CodeFile" to "Codebehind".

Thats it, you are done. Try refreshing the page and it shoild work.

/Alpesh Shah
image credit: