简体   繁体   中英

How do I return a method paramenter with RedirectToAction

I have two method signatures at the moment.

public ActionResult Edit(bool? failed)

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Update(FormCollection collection)

In the Update method when the password update fails I want to return to the Edit action with failed == true. However using the line

return RedirectToAction("Edit", true);

doesn't seem to achieve this. (I do end up at the Edit Action but the bool value is null.) How else can I redirect to an action and still have the bool value hold?

Thanks

您接近-试试这个:

return RedirectToAction("Edit", new { failed = true });

I'm afraid RedirectToAction isn't as simple as that... you need to pass the parameter as a route value dictionary. Try:

return RedirectToAction("Edit", new { failed = true }); 

See http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirecttoaction.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM