I am trying to render a view rendering without specifying the model in sitecore while trying to use fluent configuration mapping as shown in the link below.
http://www.glass.lu/Blog/GlassV4
When I go to the page, I get the below error.
The model item passed into the dictionary is of type
'Sitecore.Mvc.Presentation.RenderingModel'
but this dictionary requires a model item of type 'TestModel'.
Description: An unhandled exception occurred.
Exception Details: System.InvalidOperationException: The model item
passed into the dictionary is of type
'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary
requires a model item of type 'TestModel'.
[InvalidOperationException: The model item passed into the dictionary
is of type 'Sitecore.Mvc.Presentation.RenderingModel', but this
dictionary requires a model item of type 'TestModel'.]
System.Web.Mvc.ViewDataDictionary1.SetModel(Object value) +381
System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary)
+692 System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) +74 System.Web.Mvc.RazorView.RenderView(ViewContext
viewContext, TextWriter writer, Object instance) +137
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper,
String partialViewName, Object model, ViewDataDictionary viewData)
+167 Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +223
I haven't specified any model in the view rendering and below is my model and fluent config class.
TestModel.cs to grab items from Treelist field:
public class TestModel
{
public virtual IEnumerable<GlassGeneratedModel> MediaItems { get; set; }
}
TestModelFluentConfig.cs
public class TestModelFluentConfig: SitecoreGlassMap<TestModel>
{
public override void Configure()
{
Map(
x => x.AutoMap(),
x => x.Field(y => y.MediaItems ).FieldName("Treelist Field Name")
);
}
}
GlassMapperScCustom.cs
public static void AddMaps(IConfigFactory<IGlassMap> mapsConfigFactory)
{
// Add maps here
mapsConfigFactory.Add(() => new TestModelFluentConfig());
}
Is there some step I am missing? I am using the processors mentioned in this link for the Glass config file:
Any help would be appreciated.