In Short: Does any know a way from the base controller to get a list of actionFilters being applied to the current executing action?
The Long: I am using ASP.NET MVC 1.0 framework. I have a "RequireSSL" actionFilter that I've recreated for checking out, however, if someone leaves the checkout and goes back to the store I would like to forward them back to non-secure version of the site.
It would be helpful in the base controller (I am using a custom base controller that inherits from the default Controller) to find out what actionFilters are being applied to the current action.
I could include this into the global.asax.cs I guess, any guidance here would be appreciated.
Thanks
You can create an ActionFilter and implement OnActionExecuting. From this Attribute you could redirect them.
public sealed class MyRedirectAttributeAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!filterContext.ActionDescriptor.IsDefined(typeof(RequireSSLAttribute), true))
{
filterContext.HttpContext.Response.Redirect("~/Controller/Action");
}
base.OnActionExecuting(filterContext);
}
}true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With