我的问题非常类似于这个问题,除了我在一个子区域(右键单击创建区域)
MVC 3 – The name ‘ViewBag’ does not exist in the current context
我运行升级工具,它确实发现了该区域的web.config,但我仍然收到错误。我的布局页面很简单:
<!DOCTYPE html> <html> <head> <title>@ViewBag.Title</title> </head> <body> <div> @RenderBody() </div> </body> </html>
@model IEnumerable<ProjectName.Models.Orderviewmodel> @{ ViewBag.Title = "Index"; Layout = "~/Areas/Admin/_AdminLayoutPage.cshtml"; } <h2>Index</h2>