开发者

Can you pass a model with RedirectToAction?

I'm using mvc 2 release candidate, and am wond开发者_如何学Goering 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?


TempData["Model"] = YourModel;
Return RedirectToAction("details");

and in details action, check for TempData["Model"] != null and grab it from there

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜