I am using Ajax.BeginFrom in Index view to test the method in Home controller
@using (Ajax.BeginForm(actionName: "TestMethod",
controllerName: "Home",
ajaxOptions: new AjaxOptions
{
HttpMethod = "POST",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "TestInfo",
LoadingElementId = "Progress"
}))
{
<input type="submit" value="Search" />
<div id="TestInfo"></div>
}
And
[HttpPost]
public virtual ActionResult TestMethod()
{
return Content("ok");
}
But after submit, the Page redirect to /Home/TestMethod and show 'ok' .
I've added
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
in webconfig and
<script src="@Links.Scripts.jquery_unobtrusive_ajax_min_js" type="text/javascript"></script>
in my layout. But it still does not work asynchronous. Where is the problem?