简体   繁体   English

OnActionExecuted:找不到适合的方法来覆盖

[英]OnActionExecuted: no suitable method found to override

I am getting an error 我收到一个error

OnActionExecuted: no suitable method found to override OnActionExecuted:找不到适合的方法来覆盖

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. 我想在方法执行后执行此代码。

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 . 它期望类型为ActionExecutedContext的参数而不是ActionExecutingContext See OnActionExecuted 参见OnActionExecuted

It should be: 它应该是:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到适合的方法来覆盖webapi - no suitable method found to override webapi 错误 OnModelCreating(ModelBuilder)':找不到合适的方法来覆盖 - Error OnModelCreating(ModelBuilder)': no suitable method found to override 创建了单独的Models和Controllers项目之后,我的Initialize方法声明中出现“找不到合适的方法来覆盖” - After creating separate Models and Controllers projects, I get “no suitable method found to override” on my Initialize method declaration 在自定义Authorize属性中覆盖AuthorizeCore会导致“找不到合适的方法来覆盖”错误 - Overriding AuthorizeCore in custom Authorize attribute results in “no suitable method found to override” error SportStore:WebUI.WindsorControllerFactory.GetControllerInstance(System.Type:找不到合适的方法来覆盖 - SportStore: WebUI.WindsorControllerFactory.GetControllerInstance(System.Type: no suitable method found to override 在MVC基本控制器上覆盖设置文化的最合适方法 - Most suitable method to override on mvc base controller for setting culture 属性的OnActionExecuted方法是否始终执行? - Does the OnActionExecuted method of an attribute always execute? OnActionExecuted方法无法在.NetCore 2.0中重写 - OnActionExecuted method cant be overriden in .NetCore 2.0 有什么方法可以将值发送到MVC中受保护的重写void OnActionExecuted - Are there any way to send value into protected override void OnActionExecuted in MVC 在WebApi的ActionFilterAttribute的OnActionExecuted方法中修改HttpContent(actionExecutedContext.Response.Content) - Modify HttpContent (actionExecutedContext.Response.Content) in OnActionExecuted method of WebApi's ActionFilterAttribute
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM