locked
ViewData("Title") = "Index" RRS feed

  • Question

  • User-1503784658 posted
     
    @Code
          ViewData("Title") = "Index"
          Layout = "~/Areas/Application/Views/Shared/_Layout.vbhtml"
    End Code
     


    'ViewData' is not declared. It may be inaccessible due to its protection level.

    If I remove ViewData("Title") = "Index" then Layout throws the error.
    What am I missing?

    Tuesday, November 9, 2010 11:10 PM

Answers

  • User-797310475 posted

    It looks like you don't have a Razor config section in Views\Web.config. Take a look here (http://stackoverflow.com/questions/4136703/razor-mvc-3-rc-htmlhelper-extensions-not-found/4136773#4136773)


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 10, 2010 12:26 AM

All replies

  • User-797310475 posted

    It looks like you don't have a Razor config section in Views\Web.config. Take a look here (http://stackoverflow.com/questions/4136703/razor-mvc-3-rc-htmlhelper-extensions-not-found/4136773#4136773)


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 10, 2010 12:26 AM
  • User-1503784658 posted

    I added the sections to my web.config and it made no difference.  Got the same error.

    I am running VS 2010 on Win XP. Downloaded the MVC RC last night. I added an area then a controller and the view. The view is strongly typed to an EF entity.

    Wednesday, November 10, 2010 7:45 AM
  • User-1503784658 posted

    I find that if I use an Entity Framework object (generated from the designer) the error occurs. When I use an object I create manually, I do not get the error. 

    Wednesday, November 10, 2010 8:59 AM
  • User-1005219520 posted

    Can you reproduce this problem when you create a new MVC 3/RC1 internet application? If so, can you send me a very simple repro?

    Wednesday, November 10, 2010 2:59 PM
  • User-1503784658 posted

    Interstingly the problem is related to my entity model. I can create a empty and an internet application with an edmx and it works fine. When I add the project with my edmx to the mix and point to my objects in the ef model, if fails.

    Can you maybe give an understanding of what to look for in my ef model that can affect the access to the ViewData dictionary?

     

    Wednesday, November 10, 2010 11:56 PM