Although my code compiles and runs I am plagued by little red squiggly lines. For example, Html.BeginForm is not recognised. Although, if I type "Html." then intellisense does suggest some other methods such as Checkbox and DropDownList.
Other underlines include model and ViewBag.
I've got a reference to MVC 5.2.3.0 and the System.Web.Mvc namespace is in my web.config
This has been going on for months and is wasting a lot of my time. I'm sure it has something to do with the versions of packages I have installed but I don't understand it enough to be able to troubleshoot it.
I've rebuilt my computer, reinstalled Visual Studio 2013, and copied my code back (in chunks to try to isolate the problem) but I'm getting nowhere fast.
Can anyone help me get to the bottom of this before I switch careers?
"BeginForm()" is an extension method for both HtmlHelper and AjaxHelper classes. It returns an MVCForm object from both HtmlHelper and AjaxHelper class instances so there is not much difference but the AjaxHelper method submits the form asynchronously using JavaScript.
BeginForm(HtmlHelper, String, String, FormMethod, Object)Writes an opening <form> tag to the response and sets the action tag to the specified controller and action. The form uses the specified HTTP method and includes the HTML attributes.
make sure you have both, the controller and action method name in the BeginForm Method.
@using (Html.BeginForm(ActionmethodName, ControllerName, FormMethod.Post))
{
}
Mostly like is your config problem. Make sure your Views folder's t web.config have config like this:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.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.Routing" />
<add namespace="SixAnts" />
</namespaces>
</pages>
</system.web.webPages.razor>
using the version of your packges and your namespace
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