从onactionexecution方法中获取自定义WebViewPage中的属性.asp.net MVC 5

本文关键字:asp 属性 net MVC WebViewPage onactionexecution 方法 获取 自定义 | 更新日期: 2023-09-27 18:11:50

我有自定义的WebViewPage,在这个类中,我有我需要从ActionFilter初始化的属性。在这个过滤器我有方法onactionexecution (ActionExecutingContext filterContext)。我可以从我的自定义WebViewPage访问属性吗?

CustomViewPage

public class BaseViewPage : WebViewPage
{
    public List<IAlert> Alerts { get; set; }
    public override void Execute() { throw new NotImplementedException(); }
}

ActionFilter

public class MessageFilter : IActionFilter
{
    public void OnActionExecuted(ActionExecutedContext filterContext) { }

    public void OnActionExecuting(ActionExecutingContext filterContext)
    {//I NEED ACCESS HERE TO ALERTS PROPERTY FROM BASEVIEWPAGE
    }
}

从onactionexecution方法中获取自定义WebViewPage中的属性.asp.net MVC 5

public void OnActionExecuting(ActionExecutingContext filterContext)
{ 
      //I NEED ACCESS HERE TO ALERTS PROPERTY FROM BASEVIEWPAGE
     BaseViewPage obj = new BaseViewPage();
     obj.Alerts // your logic
}