cellik
cellik

Reputation: 2136

Razor page gives the error the name 'Model' does not exist in the current context

On a regular Razor page I have the red underlines with the error message on Model, ViewBag, etc. The intellisense does not work but the code compiles and runs fine.

There are lots of similar questions in StackOverflow but in my case this happens with a File/New project (MVC) as well as on any project that I have so it can't be a missing or incorrect line in a Web.Config etc.

I'm using VS 2015 Enterprise on Windows 10.

I had recently upgraded the PC to Windows 10 and VS2015

Any suggestions what may be causing this?

I had tried the following with no luck :

-simply waiting

-cleaning / rebuilding the project

-removing bin folder

-restarting VS

-repair install VS

Upvotes: 1

Views: 644

Answers (2)

cellik
cellik

Reputation: 2136

For those who may have a similar issue: Uninstalling and Reinstalling VS2015 solved the problem

Upvotes: 0

VictorySaber
VictorySaber

Reputation: 3164

As the code runs fine it seems as if the intellisense is being a bit poor. You say you have recently upgraded to VS2015. In my experience the intellisense in VS takes time to "bed in". Certainly in VS2013 it would perform terribly slow and wasn't better until one of the service packs came out (I think it was #2).

If this is really a case of you creating a new project and it complaining before you've made any code changes then there is nothing you can do other than run VS2015 as an Administrator a few times and wait for it to sort itself out. Get any Windows Updates / Service Packs as well.

Upvotes: 1

Related Questions