mvc no codebehind strongly typed viewdata headers not working
Asked Answered
Q

2

5

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.

Quadrille answered 5/3, 2009 at 14:40 Comment(0)
Q
6

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

Quadrille answered 5/3, 2009 at 15:27 Comment(1)
This is just as applicable to MVC 2 as 1. Although the version & PublicKeyToken changes to version 2.0 specific.... <pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter" pageBaseType="System.Web.Mvc.ViewPage" userControlBaseType="System.Web.Mvc.ViewUserControl"> <controls> <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> </controls> </pages>Reverberation
R
3

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

Thanks for posting

Recalescence answered 1/4, 2009 at 21:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.