Alex Rivera | Logout

Why doesn't my action filter get called?

Asked 2011-11-10T14:19:52.693
8

The code:

public class TheFilter : ActionFilterAttribute
{
    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        var controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
    }
}

public class NotesController : BaseController
{
    [TheFilter]
    [HttpPost]
    public ActionResult Edit(EditViewModel viewModel)
    {
        viewModel.Note.Modified = DateTime.Now;
        viewModel.Note.ModifiedBy = User.Identity.Name;
        var noteTable = StorageHelper.GetTable<Note>(viewModel.PageMeta.DataSourceID);
        noteTable.AddOrUpdate(viewModel.Note);
        return Home();
    }
}

When I debug on return Home() and step through then I bypass the action filter and go straight to the Home() method.

Am I declaring the action filter correctly?

Edit
Report

1 Answer

2

Maybe you don't reach the method directly but call Edit action from other action?
put the filter on the controller and see what happens.

answered 2011-11-10T15:10:55.400

Your Answer