I encounter an error of the form: "The model item passed into the dictionary is of type FooViewData but this dictionary requires a model item of type bar" even though I am passing in an object of the correct type (bar) for the typed user control.
views:
160answers:
2
+1
A:
What has probably happened is that the object provided when rendering the user control is actually null.
Graphain
2008-08-08 01:32:05
+3
A:
What @Graphain said is probably the reason you're seeing this error.
If you want to know why; it is because when you pass null as the controlData parameter when using RenderUserControl(), the framework will try to pass the view data from the current view context onto the user control instead (see UserControlExtensions.DoRendering method in System.Web.Mvc).
Fredrik Kalseth
2008-08-18 11:31:39