First off I'm following the demo found here and I have installed the packages correctly. I had the same issue as this article here but I was able to fix it using the answer provided. I cleaned the project, rebuilt it, and also tried closing Visual Studio and opening it again but no luck. I'm getting the following error message and I will show my View code below as well:
CS1928: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'EditorFor' and the best extension method overload 'System.Web.Mvc.Html.EditorExtensions.EditorFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>, string, object)' has some invalid arguments
View:
@using (Html.BeginForm("Contact", "Home", FormMethod.Post, new { @class = "form-horizontal" }))
{
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.Name, "Name:", htmlAttributes: new { @class = "col-sm-4 control-label" })
<div class="col-sm-8">
@Html.EditorFor(model => model.Name, true, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Email, "Email:", htmlAttributes: new { @class = "col-sm-4 control-label" })
<div class="col-sm-8">
@Html.EditorFor(model => model.Email, true, new { id = "email", htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Email)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PhoneNumber, "Phone Number:", htmlAttributes: new { @class = "col-sm-4 control-label" })
<div class="col-sm-8">
@Html.EditorFor(model => model.PhoneNumber, true, new { id = "phoneNumber", htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.PhoneNumber)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Topic, "Topic:", htmlAttributes: new { @class = "col-sm-4 control-label" })
<div class="col-sm-8">
@Html.EditorFor(model => model.Topic, true, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Topic)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Subject, "Subject:", htmlAttributes: new { @class = "col-sm-4 control-label" })
<div class="col-sm-8">
@Html.DropDownListFor(model => model.Subject, true, (SelectList)ViewBag.subject, "--Select--", new { id = "subjectList", @class = "form-control" })
@Html.ValidationMessageFor(model => model.Subject)
</div>
</div>
<div class="form-group" style="margin-top: 30px;">
<div class="col-sm-offset-4 col-sm-8">
<input type="submit" class="btn btn-primary" value="Submit" />
<input type="reset" class="btn btn-default" value="Reset" />
</div>
</div>
}
Web.config:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="HomeworkHelpers" />
</namespaces>
</pages>