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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With