Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type of namespace 'Mvc' Does not exist in the namespace Microsoft.AspNet'

I am working on a MVC project in Visual Studio 2015 (originally created in VS 2013)

It all builds correctly, but while coding, the views show alot of errors.

@{
 ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";

string quoteType = "Fee Estimate";
if (Model.Quote.QuoteType == "QuoteType")
{
}
}

In this code that is on the top of one of my views, the Viewbag, Layout & Model is all underlined showing an error.

The errors are:

Error CS0103 The name 'Model' does not exist in the current context Quilgroup C:\,,,\Index.cshtml 268

Error CS0234 The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?) Quilgroup C:...\Index.cshtml 1

I think it is something wrong with the dev enviornment, because it still compiles and runs correctly.

like image 850
Michael Avatar asked Aug 17 '15 23:08

Michael


1 Answers

Delete %localappdata%\Microsoft\VisualStudio\{version}\ComponentModelCache folder then restart Visual Studio.

I had the same problem and this solved it.

Source: After installing AspNet5RC1, can no longer open cshtml files in any previous / new MVC project

like image 69
L.Trabacchin Avatar answered Nov 14 '22 06:11

L.Trabacchin