I'm using interfaces for my Glass Mapper mappings, and I have a scenario where a view rendering I'm creating has a null datasource (due to the item being marked as never publish). I'm getting the message "the model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel' but this dictionary requires..." as a YSOD. Normally I'd create a model entry in Sitecore and hook it to the rendering, which usually covers this, but when I did it using an interface I got a message saying a constructor was required, which you can't create in an interface.

I have code in the rendering to check if it has a datasource, but it never gets there and errors out immediately. Is there any way to do what I'm trying to do with interfaces for models, or do I either a) need a concrete class, or b) need to use a controller rendering? The main reason for the interface models is there are a number of inheritances that I'm trying to set up, where a template might be inheriting from six others, and I didn't want to "junk up" the model with all of the repeated properties, if that makes sense. I'm trying to figure out the best practice here.


1 Answer 1


Please see this class:


and this blog post:


  • Very similar except for right near the end...is this something that's being considered for the main Glass project, curiously? Thanks! Apr 19, 2017 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.