Reputation: 1279
Intellisense not working for any razor html tags. Also showing Red line in all razor html tags (@Html.TexBox, @Html.DropdownList MultiSelect etc)
Three types error are showing in Visual Studio Error Window.
Error #1:
The type arguments for method 'System.Web.Mvc.Html.InputExtensions.TextBoxFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>, System.Collections.Generic.IDictionary)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Error #2:
One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?
Error #3:
Error 40 The type arguments for method 'System.Web.Mvc.Html.InputExtensions.HiddenFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Please see the attached link for more information.
Upvotes: 10
Views: 2857
Reputation: 31
This has happened to me also, apparently the intellisense stoped working so everything in the razor views was shown as an error, but the project compiled fine and even the views weren't throwing errors.
Googling I found this page: https://lostindetails.com/articles/fixing-razor-intellisense
That's what worked for me, deleting the cache folder in this location: C:\Users\username\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
changing the 14.0 for the appropiate Visual Studio version.
Credits to the guy that wrote that website.
Upvotes: 0
Reputation: 21
You need to have following section in your web.config (Root should be fine)
<system.web>
<compilation debug="true" targetFramework="4.6.1">
<assemblies>
<add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
Replace System.Web.Helpers version as per your reference.
Upvotes: 1
Reputation: 1279
Problem solved deleted all the contents from the following folder.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
Thank you all for your time. :)
Upvotes: 8
Reputation: 1173
If the close and rebuild doesn't sort it I suspect there is an issue with your project file.
Create a new ASP.net web app and copy your files over. A bit of a pain but it will probably work.
Upvotes: 0
Reputation: 94
That happens to me from time to time, usually rebuilding the project which contains the errors works for me. Did you try that?
Let me know.
Upvotes: 0