5

I am having the strangest issue using Razor views. I have two different projects and one works fine and the other doesn't. But the very odd thing is for the project that doesn't work, another colleague has the same code and same visual studio 2013 and it works fine for him. My first thoughts were the web.config and references I was using but I updated to newest MVC 5.2 nuget package and it still doesn't work.

When I type @model at top it doesn't know what it is and acts like it shouldn't be there and when I type @Html.HiddenFor(x => x.Name) it doesn't know what HiddenFor even is. The page will work if I run it but when developing the page it sees the model as Dynamic type and I can't use intellisense at all. I already deleted the suo file too.

Update : Even this doesn't work @using (Html.BeginForm....

Any ideas?

kyleb
  • 1,968
  • 7
  • 31
  • 53
  • Check this out: http://forums.asp.net/t/1950055.aspx?Upgrading+MVC+and+razor+disaster – emerson.marini Aug 06 '14 at 16:20
  • And this: http://stackoverflow.com/questions/19051550/razor-syntax-highlighting-not-working-in-vs-2012-with-mvc-5 – emerson.marini Aug 06 '14 at 16:21
  • And also this: http://stackoverflow.com/questions/9980983/visual-studio-razor-views-not-recognizing-model – emerson.marini Aug 06 '14 at 16:21
  • The project that doesn't work by chance doesn't have a custom viewpage/viewusercontrol? – Brian Mains Aug 06 '14 at 16:29
  • I have Visual Studio 2013 update 2. I just uninstalled VS 2013 and re-installed and installed Update 2 after that. – kyleb Aug 06 '14 at 16:40
  • Brian Mains - Well it had a View-Home.aspx and I didn't see it being used so I deleted it to see if your idea might work and it didn't? Am I missing something? I am doing straight MVC, not web forms. – kyleb Aug 06 '14 at 16:45
  • This happened to me on two projects not too long ago. The issue was with TFS. It appears to be a bug in Visual Studio 2013 that gets triggered if you have "Get everything when a solution or project is open" under Tools>Options>Source Control>Environment. Deselect that and everything will be okay. http://stackoverflow.com/questions/22969571/the-type-or-namespace-name-models-does-not-exist-in-the-namespace-partyinvite – Adrian Aug 07 '14 at 03:44
  • I ended up recreating the project and it now works, I am still researching what might of been different. If I find an answer I will post. – kyleb Aug 11 '14 at 16:23

1 Answers1

3

You may want to check the web.config file in the Views folder and make sure all the version number are the same as the web.config in the root.

Vinh C
  • 428
  • 3
  • 6