this is my old code
protected override bool OnPreAction(string actionName, System.Reflection.MethodInfo methodInfo)
{
if ("|Register|RegisterPage|Login|LoginPage|Logout|Service".ToLower().Contains(actionName.ToLower()))
{
return base.OnPreAction(actionName, methodInfo);
}
Customer = CustomerHelper.GetCustomer();
if (Customer.IsSeccessedLogin())
{
return base.OnPreAction(actionName, methodInfo);
}
Response.Redirect("Login.html");
return false;
}
You can create a custom action filter in two ways, first, by implementing the IActionFilter interface and the FilterAttribute class. Second, by deriving the ActionFilterAttribute abstract class.
Action filters contain logic that is executed before and after a controller action executes. You can use an action filter, for instance, to modify the view data that a controller action returns. Result filters contain logic that is executed before and after a view result is executed.
FYI, as of RC1, you do it like this:
filterContext.ActionDescriptor.ActionName
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