您可以使用 RedirectToAction 传递模型吗?
我正在使用 mvc 2 候选版本,并且想知道是否有任何方法可以使用 RedirectToAction 将模型传递给操作。
例如,我有一个编辑操作,它采用 ID,从数据库加载记录,在文本框中显示当前值,并让用户编辑并单击提交:
public ActionResult Edit(int ID)
然后我有一个针对 HttpPost 的编辑操作,它采用模型并更新数据库:
[HttpPost]
public ActionResult Edit(Administration.Models.ManagementCompanyModel model)
因为我已经拥有包含新数据的模型,所以我不想简单地重定向到“详细信息”操作,我想以某种方式重定向到“详细信息”操作并传递模型。可能的?
I'm using mvc 2 release candidate, and am wondering if there's any way to pass a model to an action using RedirectToAction.
For example, I have an edit action which takes an ID, and loads the record from a database, displays the current values in text boxes and lets the user edit and click submit:
public ActionResult Edit(int ID)
Then I have an edit action for the HttpPost which takes a model and updates the database:
[HttpPost]
public ActionResult Edit(Administration.Models.ManagementCompanyModel model)
Because I already have the model containing the new data, I don't want to simply re-direct to the Details action, I want to somehow redirect to the details action and pass the model. Possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在详细信息操作中,检查
TempData["Model"] != null
并从那里抓住它
and in details action, check for
TempData["Model"] != null
and grab it from there