In a sitecore mvc project created a .cshtml as mainlayout with the following code in it:

@using Sitecore.Mvc
@using Sitecore.Mvc.Presentation

@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<project.MVC.Models.Shared.IPageBase>

    Layout = null;

<!DOCTYPE html>

    <meta name="viewport" content="width=device-width" />
        <h1>Hello World</h1>

I assigned this as mainlayout to one of the item in Sitecore and previewed it. Following is the error displayed:

The model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary requires a model item of type 'Project.MVC.Models.Shared.IPageBase'.


Disclaimer: I work with Indra and helped him solve the problem. Adding the answer with other issues that were resolved.

Dheeraj answer was right to the question. But unfortunately it opened up a new issue called key not found exception using Glass Mappper. This was because the model properties and item fields were not matching.

After ignoring the properties to AutoMap, faced another issue. This time it is with the Glass.Mapper.Sc.Start.Config file. The namespace mentioned for the App_Start method was not pointing to the project namespace. So, corrected it and everything started working properly.


while you are inheriting from GlassView you need to do like below:

@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<Interface name or Class name>

In your case you need to do like:

@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<Project.MVC.Models.Shared.IPageBase>

If you are in old version of GlassMapper earlier to Glass V4 you need to specify the Model in your sitecore layout.

enter image description here

  • Hi @Dheeraj.I was tried.but I am getting error "The given key was not present in the dictionary." – Indrasena Dec 6 '16 at 16:14
  • can you post your full stacktrace? what version of glass you are on? – Dheeraj Palagiri Dec 6 '16 at 16:22
  • Make sure u have/deployed these configs "Glass.Mapper.Sc.config" and "Glass.Mapper.Sc.Start.config" if your glassMapper is prior to Glass4 "Glass.Mapper.Sc.CastleWindsor.config" from the folder App_Config/Include – Dheeraj Palagiri Dec 6 '16 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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