遇到这个问题 特此记录一下

由于copy   aspx页面 引起的  

copy之后   类名实原来那个的跟 你现在的文件名不一样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");
}
}
}

  

修改

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");
}
}
}

  

这时候会报错了

头疼啊,困扰我很久的一个问题,请确保此代码文件中定义的类与“inherits”属性匹配.并且该类扩展的基类(例如 Page 或 UserControl)是正确

解决办法:

修改前台 即aspx中第一行的代码 中的Inherits属性 修改成跟你类名一样

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginAPI.aspx.cs" Inherits="LoginAPI" %>

  ok  问题解决


相关文章:

  • 2021-11-08
  • 2021-08-03
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2021-12-07
  • 2021-06-17
相关资源
相似解决方案