accessing Controller.ViewData.Model is always null
106 views
Skip to first unread message
Sean Chambers
unread,
Nov 6, 2009, 11:16:28 AM11/6/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spark View Engine Dev
I am trying to convert my spark views to use ViewData.Model instead of
the namevaluecollection so that I can use AutoMapper to map my dto's
to entities before it gets into my action method.
I can access the viewdata.model from the view, but upon posting back
the data, viewdata.model is null. here is some sample code:
in my view:
<viewdata Message="string" model="MyDto" />
${Model.Id} < -- displays MyDto.Id
In my filter, OnActionExecuting on the server I am trying to do:
var model = filterContext.Controller.ViewData.Model;
but ViewData.Model is null. This is during OnActionExecuted. Is there
a trick to get the ViewData.Model to grab the values from the posted
view?
thanks
Sean
Morten Maxild
unread,
Nov 6, 2009, 11:24:17 AM11/6/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to spar...@googlegroups.com
ViewData is for passing data from the controller to the view, not for reading input in the controller/action layer.