ASP.NET MVC在执行httpPost操作后,如何正确返回Index视图?

2026-04-30 08:308阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计215个文字,预计阅读时间需要1分钟。

ASP.NET MVC在执行httpPost操作后,如何正确返回Index视图?

我在同一个控制器中创建了两个视图。问题是,我想在完成httpPost后加载第二个视图。如何在索引视图中实现这个功能?

csharppublic ActionResult Index(){ return View();}

[HttpPost]public ActionResult Index(AccountModel model){ // 处理POST请求的逻辑 // ...

ASP.NET MVC在执行httpPost操作后,如何正确返回Index视图?

return View();}

我在同一个控制器中创建了两个视图.问题是,我想在完成httppost后加载第二个视图.

索引视图

public ActionResult Index() { return View(); }

HttpPost

[HttpPost] public ActionResult Index(AccountModel model) { return View("NEXTVIEW"); }

下一个视图

public ActionResult NEXTVIEW(EpmloyeeModal model) { return View(); }

在HttpPost之后,我添加了返回nextview.而它总是返回索引视图.我试图在不同的网站上找到这样的场景,但在任何地方都找不到.

谢谢.

试试这样吧

[HttpPost] public ActionResult Index(AccountModel model) { return RedirectToAction("NEXTVIEW"); }

本文共计215个文字,预计阅读时间需要1分钟。

ASP.NET MVC在执行httpPost操作后,如何正确返回Index视图?

我在同一个控制器中创建了两个视图。问题是,我想在完成httpPost后加载第二个视图。如何在索引视图中实现这个功能?

csharppublic ActionResult Index(){ return View();}

[HttpPost]public ActionResult Index(AccountModel model){ // 处理POST请求的逻辑 // ...

ASP.NET MVC在执行httpPost操作后,如何正确返回Index视图?

return View();}

我在同一个控制器中创建了两个视图.问题是,我想在完成httppost后加载第二个视图.

索引视图

public ActionResult Index() { return View(); }

HttpPost

[HttpPost] public ActionResult Index(AccountModel model) { return View("NEXTVIEW"); }

下一个视图

public ActionResult NEXTVIEW(EpmloyeeModal model) { return View(); }

在HttpPost之后,我添加了返回nextview.而它总是返回索引视图.我试图在不同的网站上找到这样的场景,但在任何地方都找不到.

谢谢.

试试这样吧

[HttpPost] public ActionResult Index(AccountModel model) { return RedirectToAction("NEXTVIEW"); }