Anandkumar Prajapati
Anandkumar Prajapati

Reputation: 21

OnActionExecuted: no suitable method found to override

I am getting an error

OnActionExecuted: no suitable method found to override

public override void OnActionExecuted(ActionExecutingContext filterContext)
        {
         filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            filterContext.HttpContext.Response.Cache.SetNoStore();
        }

I want to execute this code after method execution.

Upvotes: 1

Views: 1869

Answers (1)

Ehsan Sajjad
Ehsan Sajjad

Reputation: 62488

Here is the method signatures :

protected virtual void OnActionExecuted (System.Web.Mvc.ActionExecutedContext filterContext);

You have incorrect type of parameter in your override. It expects a parameter of type ActionExecutedContext not ActionExecutingContext. See OnActionExecuted

It should be:

public override void OnActionExecuted(ActionExecutedContext filterContext) 
{
   // code goes here
} 

Upvotes: 3

Related Questions