I am trying to get my page to post to my Web API controller, rather than my Area/Controller/Action. Here is what I have so far, I have tried using both Html.BeginForm and A
You would need to use BeginRouteForm
as link generation to Web API routes always depends on the route name. Also make sure to supply the route value called httproute
as below.
@using (Html.BeginRouteForm("DefaultApi", new { controller="Entries", httproute="true" }))
You can explicitly tell the links to post to the root by including the leading slash:
@using (Ajax.BeginForm("", "", null, new AjaxOptions { HttpMethod = "POST", Url = "/api/Standing" }, new { id = "frmStandingAdd", name = "frmStandingAdd" }))
@using (Html.BeginForm("", "/api/Standing", FormMethod.Post, new { id = "frmStandingAdd", name = "frmStandingAdd" }))