We hereby record this issue
Caused by the copy ASPX page
After the copy operation, the original class name is different from your current file name. loginapi. aspx
public partial class yuanlai : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
object obj = Request.Cookies["username"];
if (obj == null)
{
Response.Redirect("Login.aspx");
}
}
}
Modify
public partial class LoginAPI: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
object obj = Request.Cookies["username"];
if (obj == null)
{
Response.Redirect("Login.aspx");
}
}
}
At this time, an error will be reported.
A headache that has plagued me for a long time. Make sure that the class defined in this Code File matches the "inherits" attribute and that the base class (such as page or usercontrol) of this class extension is correct.
Solution:
Modify the inherits attribute in the first line of code in aspx to be the same as your class name.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginAPI.aspx.cs" Inherits="LoginAPI" %>
OK Problem Solving