[英]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. 在更新方法中,当密码更新失败时,我想返回失败== 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?
(我的确结束于“编辑操作”,但bool值为null。)如何将我重定向到某个操作并仍然保持bool值?
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. 恐怕RedirectToAction并不那么简单...您需要将参数作为路由值字典传递。 Try:
尝试:
return RedirectToAction("Edit", new { failed = true });
See http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirecttoaction.aspx 请参阅http://msdn.microsoft.com/zh-cn/library/system.web.mvc.controller.redirecttoaction.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.