I have the following in my code:
if (Session["CurrentUrl"] != null)
{
var ip = new Uri((string)Session["CurrentUrl"]);
var ipNoPort = string.Format("{0}://{1}/{2}", ip.Scheme, ip.Host, ip.PathAndQuery);
return Redirect(ipNoPort);
}
return Home();
It checks if a Session variable is set and then redirects to that URL or lets the action return to the Home method.
Does anyone have an example of how I could convert this into an action filter?
Also can I provide the action filter with the parameter of “Home” so it knows where to go to next?
Here is an example for ActionFilter that does redirect
Edit: change from Executing to Executed and added session handling.