asp.net-mvcasp.net-mvc-3razor

Why does View.Title == ViewData["Title"] result in an error: "The name 'View' does not exist in the current context"?


I am confused with Razor ViewEngine for ASP.NET MVC.

most of you would say:

View.Title

is the same with

ViewData["Title"]

after running the application I get this

Compiler Error Message: CS0103: The name 'View' does not exist in the current context

what gives? did I miss something? am using VWD 2010 Express + ASP.NET MVC 3 R2


Solution

  • It's been changed to ViewBag in the latest RC.

    ViewBag.Title = "Test";
    

    See ScottGu's post on breaking changes in the latest MVC 3 release candidate.