I have 2 controllers.
public class HomeController : Controller
{
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
// do some stuff if controller before was ServiceController
base.OnActionExecuting(filterContext);
}
public ActionResult Index()
{
return View();
}
}
and ServiceController
with
public ActionResult Confirm()
{ return RedirectToAction("Index", "Home");}
How can I know in HomeController if action was called by RedirectToAction from Service controller? Is there any way? (I don't want to use cookies or send it in parameters, because I have lots of RedirectToAction in whole controller and I want to apply it globally for controller)
RedirectToAction is actually part of the controller itself and not an actionresult so you could override it and populate the tempdata you need from there:
Then you can check filterContext.Controller.TempData["RedirectedFromController"] is ServiceController or whatever. If you need this in more than one spot, you can create a BaseController.