试图从另一个重定向到 post 方法

Trying to redirect to post method from another

我正在尝试从另一个 post 方法重定向到 post 方法,但它似乎试图通过 Get:

重定向
[HttpPost]
[Route("Users/NewUser")]
[SystemAuthorize(PermissionForm = Form.USERS, Permissions = PermissionValue.EDIT)]
public ActionResult NewUser(ConsultUserModel m) //This is called from Consult View by post
{
    Debug.WriteLine("I'm here post");
    UserInfoModel model = GetUserInfoModel();
    return RedirectToAction("Edit",  model );
}

[HttpPost]
[Route("Users/Edit")]
[SystemAuthorize(PermissionForm = Form.USERS, Permissions = PermissionValue.EDIT)]
public ActionResult Edit(UserInfoModel edit)
{
    return View(edit);
}

当我在服务器错误中调用操作结果时:

将目标重定向为 POST 没有意义。重定向是通过向浏览器返回一个 302 响应来完成的,其中包含要重定向到的 link。然后浏览器执行 GET,这就是您所看到的。

如前所述,您无法通过设计重定向 post。

现在我将针对您的问题提出解决方案:

在我看来,您正在创建一个新用户,然后将他们重定向到一个他们可以编辑信息的地方。登陆动作不需要使用post。从那个中删除 [HttpPost],你应该可以开始了。

有另一个使用 [HttpPost] 并处理更新的操作。

如果你真的想保存属性,那么把更新用户信息的代码抽象成一个私有方法,然后从两个地方调用它。