You can save a previous page url in session. Something like this:
public ActionResult SomeCoolController(SomeCoolClass parameters) {
//some logic
var previousPageUrl = Session["PreviousPageUrl"];
if(previousPageUrl == null)
Session["PreviousPageUrl"] = Request.Url;
var isTimeToChangePreviousUrl = Session["IsTimeToChangePreviousUrl"];
if(isTimeToChangePreviousUrl != null) {
if(isTimeToChangePreviousUrl) {
Session["IsTimeToChangePreviousUrl"] = false;
Session["PreviousPageUrl"] = Request.Url;
} else {
Session["IsTimeToChangePreviousUrl"] = true;
}
} else {
Session["IsTimeToChangePreviousUrl"] = false;
}
//some return
}
Also to don't always copy/paste this code you can write your own SuperDupaActionResult which will be inherit from ActionResult and contain the code above (as a method for example).