首页新闻找找看学习计划

Asp.net mvc ActionFilterAttribute 获取不到 ActionExecutedContext Result 属性的model 的问题。

0
悬赏园豆:50 [已关闭问题] 关闭于 2015-08-30 16:58

public
class HeaderFooterFilter:ActionFilterAttribute { public override void OnActionExecuted(ActionExecutedContext filterContext) { ViewResult v = filterContext.Result as ViewResult; if (v != null) { DeskViewModel desk = v.Model as DeskViewModel; if (desk != null) { desk.HeaderData = new HeaderViewModel(); desk.HeaderData.CurrentMenu = "Home"; desk.HeaderData.UserInfo = new UserDetail(); desk.HeaderData.UserInfo.UserName = HttpContext.Current.User.Identity.Name; desk.HeaderData.MenuList = new List<MenuViewModel>(); desk.HeaderData.MenuList.Add(new MenuViewModel() { MenuName = "取消订单", MenuUrl = "OrderCancel", Value = "OrderCancel" }); desk.FooterData = new FooterViewModel(); desk.FooterData.CompanyName = "Support"; desk.FooterData.Year = DateTime.Now.Year.ToString(); } } base.OnActionExecuted(filterContext); } }

头尾部过滤一直获取不到 model

页面结果的模型拿不到

v.model一直为null,是怎么回事。

meclus的主页 meclus | 菜鸟二级 | 园豆:220
提问于:2015-08-28 15:11
< >
分享
所有回答(1)
0

我跟你遇到我的问题一样,楼主解决了吗

小酥鱼 | 园豆:202 (菜鸟二级) | 2018-06-06 16:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册