我使用 jQuery Ajax 请求来过滤 webgrid,我有几个 webgrids 和几个 ajax 请求。每个 Ajax 请求调用相同的 ActionResult 方法,但传递不同的参数。这个想法是根据我提供的参数调用正确的方法。然而事实并非如此。
我收到此错误:
The current request for action 'FilterGrid' on controller type 'UserManagerController' is ambiguous between the following action methods:<br>System.Web.Mvc.ActionResult FilterGrid(Int32, Int32, System.String, System.String, Int32, System.String) on type UserManager.Controllers.UserManagerController<br>System.Web.Mvc.ActionResult FilterGrid(System.String) on type UserManager.Controllers.UserManagerController
我的 jQuery
function filterGrid() {
var filters = getFilterVals();
$.ajax({
url: '@Url.Action("FilterGrid", "UserManager")',
type: "POST",
async: true,
dataType: "html",
data: "group=" + filters.group,
success: function (data) {
$('#webgrid-wrapper').empty().html(data);
},
error: function (data) {
}
});
}
我的控制器代码
[HttpPost]
public ActionResult FilterGrid(int alf, int brad, string username, string group, int isactive, string email)
{
List<UserManager.Models.vw_UserManager_Model> modelList = DAL.getGridUsers(alf, brad, username, group, isactive, email);
switch (alf)
{
case 1:
Session["chkBoxAlf"] = 1;
break;
case 0:
Session["chkBoxAlf"] = 0;
break;
}
switch (brad)
{
case 1:
Session["chkBoxBrad"] = 1;
break;
case 0:
Session["chkBoxBrad"] = 0;
break;
}
switch (isactive)
{
case 1:
Session["chkBoxIsActive"] = 1;
break;
case 0:
Session["chkBoxIsActive"] = 0;
break;
}
Session["txtFilterUsername"] = username;
Session["txtFilterGroup"] = group;
Session["txtFilterEmail"] = email;
return PartialView("~/Views/Partial/_WebGridUserManagerUsers.cshtml", modelList);
}
[HttpPost]
public ActionResult FilterGrid(string group)
{
return PartialView("~/Views/Partial/_WebGridUserManagerGroups.cshtml");
}
我的断点
[HttpPost]
public ActionResult FilterGrid(string group)
{
return PartialView("~/Views/Partial/_WebGridUserManagerGroups.cshtml");
}
不会被击中。有谁知道如何解决这个问题?