c# – 解析器错误消息:此处不允许使用’FCR2.abs’,因为它不扩展类’System.Web.UI.Page’

有谁知道如何解决这个问题?

这是我运行应用程序时的分析器错误

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: 'FCR2.abs' is not allowed here because it does not extend class 'System.Web.UI.Page'.

Source Error: 

Line 1:  <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="404.aspx.cs" Inherits="FCR2.abs" %>
Line 2:  <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
Line 3:  </asp:Content>


Source File: /404.aspx    Line: 1 `enter code here`

这是我的404.aspx文件

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="404.aspx.cs" Inherits="FCR2.abs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Page Not Found</h1>
    <p>You have come here by mistake or the page you are trying to view is no longer availible.</p>
    <p>Go back to the <a href="Default.aspx">Home Page</a></p>
</asp:Content>

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

这是404.aspx.cs代码

namespace FCR2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender,EventArgs e)
        {

        }
    }
}

这是404.aspx.designer.cs代码

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated. 
// </auto-generated>
//------------------------------------------------------------------------------

namespace FCR2 {


    public partial class abs {
    }
}

解决方法

确保您为代码的该部分使用相同的类名.

如果您使用abs,则需要将其重命名为:

namespace FCR2 
{     
   public partial class abs : System.Web.UI.Page     
   {         
      protected void Page_Load(object sender,EventArgs e)              {          
      }     
   } 
}

相关文章

目录简介使用JS互操作使用ClipLazor库创建项目使用方法简单测...
目录简介快速入门安装 NuGet 包实体类User数据库类DbFactory...
本文实现一个简单的配置类,原理比较简单,适用于一些小型项...
C#中Description特性主要用于枚举和属性,方法比较简单,记录...
[TOC] # 原理简介 本文参考[C#/WPF/WinForm/程序实现软件开机...
目录简介获取 HTML 文档解析 HTML 文档测试补充:使用 CSS 选...