Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does VS2015RC says "The ViewBag doesn't exist in the current context", where as VS2013 says no errors?

I am opening the same MVC solution in VS2013 and VS2015RC, exact same code, but my VS2015RC tells me there are bunch of errors on my .cshtml pages where as VS2013 says no errors. The main problem is I don't get any intellisense because of the errors in VS2015.

What could be causing this? Also, when I Build the solution in VS2015, it says it succeeded? Code snippet:

<!DOCTYPE html>

<html>
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-2.1.3.min.js")" type="text/javascript"></script>
    <meta name="description" content="The description of my page" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
    <div id="header">
        <div class="title">ABC</div>
    </div>
    <div id="categories">
        @{ Html.RenderAction("Menu", "Navigation"); }
    </div>
    <div id="content">
        @RenderBody()
    </div>
</body>
</html>

vs2013enter image description here vs2015enter image description here

like image 761
anish Avatar asked Jul 05 '15 16:07

anish


1 Answers

try add this line inside each .cshtml

@inherits System.Web.Mvc.WebViewPage<dynamic>
like image 114
liujialiang Avatar answered Oct 11 '22 12:10

liujialiang