Is there a way to inject the referrer action from an action filter?
Lets say I have a view that comes from action X. In dies view I call action Y and I want to redirect again to action X. (There are multiple X actions that call action Y). I thought that it could be nice if I had a parameter call referrerAction and an action filter that filled it with the previous action. Is it possible?
Thanks.
Here’s how I do:
Now, you mark you X actions with [ReturnPoint] and call RedirectOrReturn() if you want to return back.
I do not use UrlReferrer because it can be wrong and I have no control over its value. With ReturnPoint, you can also have groups, e.g. [ReturnPoint(“Orders”)] and RedirectOrReturn(“Orders”).
Of course, you can have more automatic behaviour in OnActionExecuted – e.g. it can check if returned result is Redirect, and automatically go to ReturnPoint if it has value. Or you can control this with [ReturnPoint(Automatic=true)], and so on.