के लिए हो रही से पहले मॉडल करने के लिए मैं निम्नलिखित है जोड़ें:OnActionExecuting कार्रवाई
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
if (filterContext == null)
{
throw new ArgumentNullException("filterContext");
}
var model = filterContext.Controller.ViewData.Model as BaseViewModel;
if (model == null)
{
model = new BaseViewModel();
filterContext.Controller.ViewData.Model = model;
}
model.User = (UserPrincipal)filterContext.HttpContext.User;
model.Scheme = GetScheme();
}
अब जब कि के माध्यम से कदम मैं देख सकता हूँ उपयोगकर्ता और मॉडल पर योजना आबादी जा रहा है।
जब तक मैं कार्रवाई में आता हूं, हालांकि वे दोनों शून्य हैं?
मैं यहाँ क्या गलत कर रहा हूं?
और इसमें जोड़ना, क्या यह मॉडल में जोड़ने का उचित तरीका है?
[InjectStandardReportInputModel]
public ActionResult Header(BaseViewModel model)
{
//by this point model.Scheme is null!!
}
आप भी अपने 'Controller' कोड पोस्ट कर सके तरह तो क्या होगा? आप सुनिश्चित हैं कि आपने 'वर्ग' परिभाषा या लागू 'क्रिया'/एस में 'विशेषता' जोड़ा है? – xandercoded
जोड़ा गया एक्शन कोड - क्या आप कह रहे हैं कि यह काम करना चाहिए? ... – iwayneo
एक ही मुद्दे पर चर्चा की गई है http://stackoverflow.com/questions/4766156/all-viewmodels-inherit-from-baseviewmodel-can-i-set -इस-अप-इन-ऑनएक्शन एक्सचेंज –