ASP.NET MVC 错误 : Page is not allowed here because it does not extend class 'System.Web.Page'

标签 asp.net asp.net-mvc

我有一个新的 ASP.NET MVC 项目(我的第一个),并且我使用 1 个 Controller 、 View 和模型运行良好。添加新的 Controller 和 View 后,当我尝试运行项目时,我的第一个 View 开始抛出此错误消息:

描述:解析服务此请求所需的资源时发生错误。请查看以下特定解析错误详细信息并适当修改您的源文件。

Parser Error Message: 'PeopleManagement.Web.Views.Search.Search' is not allowed here because it does not extend class 'System.Web.UI.Page'.

Source Error: 


Line 1:  <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Master.Master" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="PeopleManagement.Web.Views.Search.Search" %>
Line 2:  <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
Line 3:  </asp:Content>

这是我的该 aspx 页面的代码隐藏的全部内容:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace PeopleManagement.Web.Views.Search
{
    public partial class Search : ViewPage
    {
    }
}

我不确定我的应用程序中发生了什么变化导致了这种情况。看起来 VS 可能会将其视为 Webforms 应用程序而不是 MVC 应用程序?关于我应该从哪里开始排除故障有什么想法吗?

最佳答案

我以前也遇到过这种情况。无法解释它。我最终通过再次创建第一个 View 并复制和粘贴标记来重建它。也可以尝试关闭 VS 并重新启动。

关于ASP.NET MVC 错误 : Page is not allowed here because it does not extend class 'System.Web.Page' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/381008/

相关文章:

asp.net - 如何加快我的网站速度(后台)

c# - IIS 提示使用 LDAP 身份验证的身份模拟

javascript - DropdownFor 并为每个 <option> 分配 Class

c# - 为 asp.net MVC 静态资源设置合成路由

asp.net - BrowserLink MVC 6 - 不工作 - 没有注入(inject)额外代码

c# - 只读时无法获取带有文本框的文本?

c# - Sitecore 8 MVC ajax调用路由寄存器

c# - 通用实现中表值参数的 Dapper

asp.net-mvc - 如何在 MVC 3 中将列表或集合从 View 返回到 Controller ?

c# - Ajax.beginform 执行完整回发而不是部分回发