Ad
In ASP.NET MVC I Encounter An Incorrect Type Error When Rendering A User Control With The Correct Typed Object
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.
Ad
Answer
What @MattMitchell 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).
Ad
source: stackoverflow.com
Related Questions
- → Function Undefined in Axios promise
- → AngularJS directive: "templateUrl" doesn't work while "template" works
- → JavaScript in MVC 5 not being read?
- → URL routing requires /Home/Page?page=1 instead of /Home/Page/1
- → NumericTextBox Loses Value using Html.TextBoxFor, not HTML
- → Does the fact that every page is reachable through www.example.com and www.example.com/index have any SEO impact?
- → SEO tags in Umbraco
- → Add dynamic divs around 6 image urls using jquery
- → ASP.NET Mvc 5 return View with seo friendly url
- → MVC SEO targeting Italy from a .uk.com domain
- → Using an object I never defined in JQuery
- → Pass json data from Google Maps to MVC controller with AJAX
- → Displaying Unique SEO code two times in the URL when change length 2 to 5
Ad