Asp.net MVC - 从一个自定义的行为过滤器访问视图模型 [英] Asp.net mvc - Accessing view Model from a custom Action filter

查看:142
本文介绍了Asp.net MVC - 从一个自定义的行为过滤器访问视图模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访​​问传递给在OnActionExecuted动作过滤器视图的模型数据。有谁知道这是否可能?

I am trying to access the Model data passed to the view in the action filter OnActionExecuted. Does anyone know if this is possible?

我试图做这样的事情:

public override void OnActionExecuted(ActionExecutedContext filterContext)
{
    //get model data
    //...

    sitemap.SetCurrentNode(model.Name);
}

任何意见?

推荐答案

该模型是:

filterContext.Controller.ViewData.Model

这篇关于Asp.net MVC - 从一个自定义的行为过滤器访问视图模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆