c# - 解析器错误消息 : 'FCR2.abs' is not allowed here because it does not extend class 'System.Web.UI.Page'

标签 c# .net asp.net visual-studio-2010

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

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

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)              {          
      }     
   } 
} 

关于c# - 解析器错误消息 : 'FCR2.abs' is not allowed here because it does not extend class 'System.Web.UI.Page' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6981791/

相关文章:

.net - 如何首先从数据库 EF 模型向现有代码添加其他表?

html - 去除左右两侧的白色间隙

asp.net - 不允许更改“ConnectionString”属性。连接的当前状态为打开

c# - 如何创建具有依赖关系的单元测试

c# - C# 中的 PriorityQueue 不适用于自定义比较器

c# - Microsoft 依赖注入(inject)和逆变

c# - 当前上下文中不存在名称 'HttpUtility' (winform)

c# - 你什么时候应该等待任务?

c# - Task<T> 与 C# 中的异步委托(delegate)?

c# - .NET winforms 应用程序在不使用 ClickOnce 的情况下更新自身的最佳方式是什么?