Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
asp.net c#代码文件工作不正常_C#_Asp.net - Fatal编程技术网

asp.net c#代码文件工作不正常

asp.net c#代码文件工作不正常,c#,asp.net,C#,Asp.net,我正在尝试将代码文件添加到asp.net母版页。我让它在单个页面上正常工作,但无法在母版页上正常工作 在我的aspx母版页中,我有: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master.cs" Inherits="Master.Master" %> 代码如下: namespace Master { using System; public partial class Master : S

我正在尝试将代码文件添加到asp.net母版页。我让它在单个页面上正常工作,但无法在母版页上正常工作

在我的aspx母版页中,我有:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master.cs" Inherits="Master.Master" %>
代码如下:

namespace Master
{
    using System;

    public partial class Master : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write("ALEX");
            Response.End();
        }
    }
}
据我所知,我所有的声明都是正确的,但我得到的错误是:

ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
这句话:

Line 5:      public partial class Master : System.Web.UI.Page
它是红色的。我以前有过这个错误,但我确信我所有的代码都是正确的,所以我不确定为什么会出现这个错误


可能主文件需要不同的设置,或者它在母版页上的工作方式不同

定义母版页代码隐藏类时,要继承的基类是
System.Web.UI.MasterPage
,而不是
System.Web.UI.page

Line 5:      public partial class Master : System.Web.UI.Page