ASP.NET AJAX.BeginForm发送两次请求并添加重复条目

ASP.NET AJAX.BeginForm发送两次请求并添加重复条目,asp.net,ajax,asp.net-mvc,request,submit,Asp.net,Ajax,Asp.net Mvc,Request,Submit,我有一个老项目要做(asp.NETMVC)。当使用Ajax.BeginForm和提交按钮时。它调用动作方法两次。原因可能是什么 控制器源: PatientDataProvider.AddPatient(patient); return Json(new { redirection = "goToIndex" }, JsonRequestBehavior.AllowGet); HTML: @using (Ajax.BeginForm("AjouterPatient", "Patient", ne

我有一个老项目要做(asp.NETMVC)。当使用Ajax.BeginForm和提交按钮时。它调用动作方法两次。原因可能是什么

控制器源:

PatientDataProvider.AddPatient(patient);
return Json(new { redirection = "goToIndex" }, JsonRequestBehavior.AllowGet);
HTML:

@using (Ajax.BeginForm("AjouterPatient", "Patient", new AjaxOptions { HttpMethod = "POST", OnSuccess = "OnSuccess" }))
这是按钮:

<button class="btn btn-sm btn-success" type="submit">
   <i class="ace-icon fa fa-check"></i>
       Save
</button>

拯救
OnSuccess方法:

    <script type="text/javascript">
        function OnSuccess(data)
        {
            window.location.href = "@Url.Action("Index", "Home")";
        };

//other methods
        jQuery(function ($) {...}

函数OnSuccess(数据)
{
window.location.href=“@Url.Action(“Index”,“Home”)”;
};
//其他方法
jQuery(函数($){…}

提前谢谢。

当你想重定向时,你到底为什么要使用ajax?@Stephen:除了重定向,我还有其他测试要做?(你显示的代码只是
location.href=…
)我假设的代码只包含重定向,但我必须测试。我这样做只是为了简化事情