Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. return RedirectToAction("Action1", "YourControllerName");
  2.  
  3. public ActionResult Action2(string backUrl)
  4. {
  5. if (string.IsNullOrEmpty(backUrl))
  6. {
  7. throw new ArgumentNullException("backUrl");
  8. }
  9. ViewBag.ReturnUrl = backUrl;
  10. //your work
  11. return View();
  12. }
  13.  
  14. [HttpPost]
  15. public ActionResult Action2(YourModel model, string backUrl)
  16. {
  17. //your work
  18. return Redirect(backUrl);
  19. }
  20.  
  21. ...
  22. @Html.ActionLink("text", "Action2", new { backUrl = Url.Action("Action1") })
  23. ...
  24.  
  25. ...
  26. <input name='backUrl' type='hidden' value='@ViewBag.ReturnUrl' />
  27. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement