I have a MVC5 project I am trying to solve some issues with where I am not getting intellisense on the System.Web.MVC components
In the Web.Config in my views folder I have the following;
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Configuration" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="Helpers" />
<add namespace="Common.Net.Mvc" />
<add namespace="Common" />
<add namespace="MvcSiteMapProvider.Web.Html" />
<add namespace="MvcSiteMapProvider.Web.Html.Models" />
</namespaces>
</pages>
</system.web.webPages.razor>
However when I then reference for example Url., ViewBag or Html.ActionLink etc(also if I reference my Common class which is a .resx generated file). I get errors saying they do not existing the current context.
I can compile and run the code successfully and the pages render just fine, it would be nice to eliminate these errors though and get the intellisense I usually get.
I am running VS2017 Community and I have the Razor extension installed and updated. I have intellisense on other projects it just seems to be this one.
Ok, After much searching and wasting of time, this answer here fixed the issue;
The name 'ViewBag' does not exist in the current context - Visual Studio 2015
Here is a run down of the steps I took (the removal and deletion of files may not be required);
C:\\Users\\your.name.here\\AppData\\Local\\Temp\\Temporary ASP.NET Files
C:\\Users\\your.name.here\\AppData\\Local\\Microsoft\\VisualStudio\\14.0\\ComponentModelCache
Note the above alone didn't fix so then I applied the following in conjunction witht he above.
This rebuilt the nuget references and the intellisense came back. Hopefully one day, somewhere this will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.