Reputation: 149
I get this error in VS 2022 the ASP.NET application is running, but this error is appearing. I check the configs according other answers I found in this topic, but everything looks OK.
my cshtml file:
@{
ViewBag.Title = "Index";
Layout = null;
}
in web.config (all about the MVC config):
<appSettings>
<add key="webpages:Version" value="2.0.0.0"/>
<-- more settings here -->
</appSettings>
...
<namespaces>
<add namespace="System.Web.Helpers"/>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
....
</namespaces>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="..." culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.8.0" newVersion="5.2.8.0"/>
</dependentAssembly>
the error:
Error CS0103 The name 'ViewBag' does not exist in the current context
how can I solve this problem?
Upvotes: 0
Views: 121