protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (!ApplicationState.Contain(this.CurrentController) && this.Model != null) { ApplicationState.SetValue(this.CurrentController, this.Model.GetType()); } }
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) { if (modelType.Equals(typeof(IModel))) { string controllerName = CommonMethod.ParseString(controllerContext.RouteData.Values["controller"]); //var modelList = Ivs.Core.Web.Controllers.BaseController.ModelList; if (ApplicationState.Contain(controllerName)) { Type type = ApplicationState.GetValue <Type>(controllerName); if (type != null) { var model = Activator.CreateInstance(type); bindingContext.ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, type); return(model); } } } return(base.CreateModel(controllerContext, bindingContext, modelType)); }