Wednesday, 20 September 2017

How do I redirect to the previous action in ASP.NET MVC?

public ActionResult MyNextAction()
{
    return Redirect(Request.UrlReferrer.ToString());
}
alternatively, touching on what darin said, try this:
public ActionResult MyFirstAction()
{
    return RedirectToAction("MyNextAction",
        new { r = Request.Url.ToString() });
}
then:
public ActionResult MyNextAction()
{
    return Redirect(Request.QueryString["r"]);
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive