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,是怎么回事。
我跟你遇到我的问题一样,楼主解决了吗