model-view-controller - mvc 没有代码隐藏强类型 View 数据头不起作用

标签 model-view-controller header code-behind strong-typing viewdata

我将它添加到我的标题 <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>并且能够访问 ViewData 及其所有内部结构以及所有 mvc 对象,如 url 和 html。一旦我添加“System.Web.Mvc.ViewPage<app.Models.tTable> ”,我就无法访问任何 mvc 类和辅助方法。我很困惑为什么会这样。我最近完成了从 mvc preview 5 到 rc1 的升级,但是我到 rc1 的过渡是完美的,没有任何错误或错误。

最佳答案

在钓鱼(大量钓鱼)之后,我找到了答案,这是因为我没有阅读官方发行说明,而是浏览了博客中的教程,但是任何人都需要更换 <pages>在“/Views”目录中的 web.config 文件中的节点

<!--
        Enabling request validation in view pages would cause validation to occur
        after the input has already been processed by the controller. By default
        MVC performs request validation before a controller processes the input.
        To change this behavior apply the ValidateInputAttribute to a
        controller or action.
    -->
    <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <controls>
        <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>

我从预先构建的 web.config 文件中添加了评论

关于model-view-controller - mvc 没有代码隐藏强类型 View 数据头不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/615044/

相关文章:

php - 在哪里验证 MVC 应用程序中的表单引荐来源网址和 token ?

php - MVC验证建议

IFRAME 中的 PHP "header (location)",加载到 _top 位置?

c++ - Doxygen 不会在子目录中找到标题

c# - CSS,如何仅在第一页加载时将最小高度/宽度设置为屏幕高度/宽度?

c# - 如何从代码隐藏刷新自定义 wpf 用户控件?

model-view-controller - 我应该如何在MVC中制作类图?

java - Spring MVC - 页面之间的变量,以及取消设置 SessionAttribute

regex - emacs org 模式,只搜索标题

javascript - 如何从 ASP.NET 中的 MenuItem 调用 onClick 事件?