30

I just updated an mvc4 project (using vs2012) to mvc5. After having a lot of issues related to dependencies, I finally found this tutorial and straightened things up so that it builds without issues However, I have to intellisense for any of the views (.cshtml files): @using, @model, @html.*, @styles... nothing works. I must have broken the reference to the razor view engine not being able to parse them properly. I have double checked the web.configs and cannot see anything. Any ideas? Thanks.

C1pher
  • 1,933
  • 6
  • 33
  • 52
user906573
  • 644
  • 1
  • 6
  • 22
  • 3
    No can do woithout VS2013 it seems: Look at this - http://stackoverflow.com/questions/17968304/create-and-run-mvc-5-project-in-vs-2012/19124665#19124665 – Jan Löwgren Oct 21 '13 at 22:08
  • Please vote for the corresponding bug at Microsoft connect: https://connect.microsoft.com/VisualStudio/feedback/details/806348/razor-intellisense-does-not-work-in-visual-studio-2012-after-upgrading-to-mvc-5-razor-3 – Nathan Oct 23 '13 at 19:05
  • "MVC 5/Razor 3 tooling support for VS 2012 has not shipped yet. We hope to ship this support in Mid November (2013)." – Chris S Nov 04 '13 at 18:49

6 Answers6

30

Went through the same agony, and was working without intellisense in views for about 3 weeks. Then I finally found it. It started working when I switched webpages setting to version 3 in web.config.

So in my web.config this was version 2.0.0.0, after i updated to 3.0.0.0 it started to work

  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
     ...
</appSettings>

Hopfully this was your issue to and will help becouse I feel your pain :)

--------------------------------------------------------

UPDATE: For others who are still looking for a fix for this issues in a post-MVC5 update, this helped me: In the ~/Views/web.config, updating from MVC 5.2.2.0 to 5.2.3.0 using Nuget did not update this line:

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

Updating 5.2.2.0 to 5.2.3.0 brought Intellisense back to life. You may have to close the view and re-open it to get the Intellisense to load.

Liam
  • 27,717
  • 28
  • 128
  • 190
Dennis Puzak
  • 3,726
  • 3
  • 23
  • 22
17

ASP.NET and Web Tools 2013.1 for Visual Studio 2012 has now been released and should resolved the MVC5 intellisense issue with VS 2012.

This release brings a ton of great improvements, and include some fantastic enhancements to ASP.NET MVC 5, Web API 2, Scaffolding and Entity Framework to users of Visual Studio 2012 and Visual Studio 2012 Express for Web.

You can download the update: http://blogs.msdn.com/b/webdev/archive/2013/11/18/announcing-release-of-asp-net-and-web-tools-2013-1-for-visual-studio-2012.aspx

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
hatsrumandcode
  • 1,871
  • 2
  • 19
  • 21
7

I had try all that and other stuffs in my case the solution was changes this line that is in Views-WebConfig inside

  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

to

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Diego_DX
  • 1,051
  • 1
  • 20
  • 33
1

While the above answers may resolve most of these problems, my problem was apparently caused by a VS Extension I had installed. Please see Answer provided by Emran Hussain here: Visual Studio 2013 IntelliSense stops working for ASP.NET MVC5 Controllers

His answer was spot on for me, even though my problem was with intellisense on my Razor Views only. I disabled the extension, and restarted VS2013 and intellisense is working again with no problems. Like Emran, I'm hesitant to blame the maker of the extension (AzureXplorer by ClumsyLeaf software), because I think this may be a VS issue?

Community
  • 1
  • 1
PTK
  • 446
  • 4
  • 6
1

None of the previous solutions worked for me. I'm using VS 2012 and MVC 5. This is what I did to make it work:

  1. I installed Web Tools 2013 as explained in the following link: http://blogs.msdn.com/b/webdev/archive/2013/11/18/announcing-release-of-asp-net-and-web-tools-2013-1-for-visual-studio-2012.aspx
  2. I checked /web.config and /Views/web.config and fixed some version issues. In my case I have MVC 5.2 so it was important to do a correct MVC biding like this:

Also, it's important to mark this:

<add key="webpages:Version" value="3.0.0.0" />
Francisco Goldenstein
  • 13,299
  • 7
  • 58
  • 74
0

The tooltip of the "@model" tag at the very top of my razor view file stated that autofac 3.4.0.0 could not be found. All my projects used Autofac 3.1.5, so I added a redirect in web.config to quickly work around the issue:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-3.4.0.0" newVersion="3.1.5" />
        </dependentAssembly>
        ...

My intellisense was back and I then deferred the final fix to a low prio task :D

o_o
  • 938
  • 1
  • 9
  • 14