Saturday, October 19, 2013

Best way to handle Return URLs in an MVC environment



public ActionResult MembersReport(int? id)
        {
            Session["CurrentUrl"] = Request.Url.ToString();

            // do whatever you want with your model...

            return View();
        }


        [HttpPost]
        public ActionResult EditMembers()
        {
            // do whatever you want with your model...

           return Session["CurrentUrl"] == null ? MembersReport(null) : Redirect(Session["CurrentUrl"].ToString());
        }