POST http://localhost:55703/ValidStep1 404(未找到)

POST http://localhost:55703/ValidStep1 404 (Not Found)

我想在单击按钮时转到另一个页面,但是当我单击时没有任何反应并且我卡在初始页面上 + 我遇到此错误:

POST http://localhost:55703/Home/ValidStep1 404(未找到)

这是我的代码:

HomeController.cs

[HttpPost]
public JsonResult ValidStep1(Dictionary<string, List<string>> listUsers){
//some code
}

Index.cshtml

jQuery.post('/Home/ValidStep1', { listUsers: listUser }, function (data) {
  if (data) {
    document.location.replace("@ViewBag.nextStep");
  }
  else {
    document.location.replace("@ViewBag.errorStep");
  }
});

你有什么想法吗?

好的,现在可以使用以下代码了。但我不知道为什么。好像……和上面一样

jQuery.ajax({
  type: 'POST',
  url: '@Url.Action("ValidStep1", "Home")',
  data: { listUsers: listUser },
  success: function (data) {
      document.location.replace("@ViewBag.nextStep");
  },
  error: function () {
      document.location.replace("@ViewBag.errorStep");
  }
});