public class CreateOrganizationController : UmbracoApiController
{
[System.Web.Http.HttpPost]
public void CreateNewOrganization(NewSiteModel organization)
{ /*some code*/}
}
but after rendering the page in action form i have path:
form id="form0" action="<strong>/umbraco/RenderMvc/</strong>Umbraco/Api/CreateOrganization/CreateNewOrganization" method="post">
the issue is /umbraco/RenderMvc/, if i change path on the page to /Umbraco/Api/CreateOrganization/CreateNewOrganization its work fine, is there any idea how can i get right path?
Call UmbracoApiController via Ajax.BeginForm
Hi there,
I have some issue with calling Api controller via Ajax.BeginForm,
form in cshtml (rendering in partial view):
@using (Ajax.BeginForm("/Umbraco/Api/CreateOrganization/CreateNewOrganization", new AjaxOptions { HttpMethod = "POST" }))
{
@Html.Label("Site Name")
@Html.TextBoxFor(m => m.SiteName, new { required = "required" })
@Html.ValidationMessageFor(m => m.SiteName)
@Html.Label("Site Description ")
@Html.TextAreaFor(m => m.Description, 3, 3, null)
Cancel
}
controller:
public class CreateOrganizationController : UmbracoApiController
{
[System.Web.Http.HttpPost]
public void CreateNewOrganization(NewSiteModel organization)
{ /*some code*/}
}
but after rendering the page in action form i have path:
form id="form0" action="<strong>/umbraco/RenderMvc/</strong>Umbraco/Api/CreateOrganization/CreateNewOrganization" method="post">
the issue is /umbraco/RenderMvc/, if i change path on the page to /Umbraco/Api/CreateOrganization/CreateNewOrganization its work fine, is there any idea how can i get right path?
Thanks
Hi Sasha,
Try to use like that:
Hi Alex,
It did't help.
Usually i use this form for access SurfaceController, but in this case i want access ApiController
Ok,
it's look like i found my solution:
@using (Ajax.BeginForm(null, null, new AjaxOptions { HttpMethod = "POST" }, new { @action = "/Umbraco/Api/CreateOrganization/CreateNewOrganization" }))
is working on a reply...