SHARE
TWEET

Untitled

a guest Jul 17th, 2017 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ...
RAW Paste Data
Top