你可以在Ajax post请求成功后使用JavaScript来进行重定向。以下是一个示例代码:
在你的视图页面中,添加一个按钮和一个包含Ajax post请求的脚本:
在你的控制器中,添加一个处理Ajax post请求的动作方法和一个重定向的动作方法:
[HttpPost]
public ActionResult Action()
{
// 处理Ajax post请求的逻辑
return Json(new { success = true }); // 返回一个Json结果
}
public ActionResult RedirectAction()
{
// 处理重定向的逻辑
return View(); // 返回一个视图
}
这样,当用户点击按钮时,Ajax post请求将被发送到/Controller/Action
动作方法,并在请求成功后重定向到/Controller/RedirectAction
动作方法。请确保将/Controller/Action
和/Controller/RedirectAction
替换为你实际使用的控制器和动作方法的URL。