mvc 没有代码隐藏强类型视图数据标头不起作用

发布于 2024-07-14 12:11:56 字数 362 浏览 7 评论 0原文

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

I add that to my header <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> and am able to access ViewData and all its internals as well as all the mvc objects like url and html. As soon as I add "System.Web.Mvc.ViewPage<app.Models.tTable>" I have no access to any mvc classes and helper methods. I am confused on why this is. I have done an upgrade from mvc preview 5 to rc1 recently but my transition to rc1 was flawless without any errors or bugs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

疯了 2024-07-21 12:11:56

在钓鱼(大量钓鱼)后,我找到了答案,这是因为我没有阅读官方发行说明,而是浏览了博客中的教程,但任何人要使其正常工作,您都需要替换 ; 节点位于“/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 文件的注释

After fishing (alot of fishing) around I found the answer, this is because I didn't read the official release notes rather ran through a tutorial from a blog but anywho to get this working you need to replace the <pages> node in the web.config file in your "/Views" directory with

<!--
        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>

I added the commenting from a pre built web.config file

つ可否回来 2024-07-21 12:11:56

有一个技巧。 /Views 文件夹下有一个 web.config。 哇,我没看到。

感谢您发帖

There's a trick. There's a web.config under the /Views folder. Wow, I didn't see that.

Thanks for posting

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文