asp.net - 此处不允许页面,因为它不扩展类 'System.Web.UI.MasterPage'

标签 asp.net

我正在使用母版页创建一个网站,效果很好。但是当我将实体数据模型和一些检索代码添加到登录页面后,出现了一些错误

代码就像

var tombstoneQuery = from t in crnnsupContext.Tombstones.Include("ProvState")
                             where t.RegNumber == _username
                             select t;
List<Tombstone> tombstoneResult = tombstoneQuery.ToList();
Cache.Insert("Tombstone", tombstoneResult);

当我尝试将列表放入缓存时,发生了第一个错误,错误显示“线程正在中止。在我将cache.insert语句设置为命令后,这个错误消失了,但下一个错误出现了

Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: 'OnlineRenewal.Renewal' is not allowed here because it does not extend class 'System.Web.UI.MasterPage'.

Source Error: 


Line 1:  <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="renewal.Master.cs" Inherits="OnlineRenewal.Renewal" %>
Line 2:  
Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

续订是母版页,我没有对其进行任何操作。 任何人都可以帮忙吗?非常感谢

续订页面的代码。 (那里有注释)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace OnlineRenewal
{
public partial class renewal : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
}




<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="renewal.Master.cs" Inherits="OnlineRenewal.Renewal" %>

最佳答案

这告诉你OnlineRenewal.Renewal不是母版页。

确保它有 <%@ Master %>指令位于页面顶部,或将导致此错误的页面的继承属性更改为其他内容。

关于asp.net - 此处不允许页面,因为它不扩展类 'System.Web.UI.MasterPage',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9640787/

相关文章:

asp.net - 无法加载文件或程序集 App_Licenses

javascript - 如何以编程方式将图片上传到 Facebook?

ASP.NET Viewstate - 寻求有关支持文章的澄清

c# - 在 .net 中获取 ssl 证书

c# - 调用 "Configure Data Source..."时出错。详情 : Exception has been thrown by the target of an invocation

JavaScript 运行时错误 : Object doesn't support property or method 'on'

javascript - 如何将 User 对象作为参数传递给 node.js 的 Express api(如 asp.net)

javascript - JQuery的Ajax是否引用web.config中的maxJsonLength属性

c# - startup.cs的Configure方法中如何使用ConfigurationBinder

c# - Entity Framework 有时不将结果返回到列表