0

While accessing the link on website got the below error.

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 'SLB.Entities.PrivateCommunity.PrivateCommunityFAQModel'.

Source Error: 

Line 81:         
Line 82:             
Line 83:                 @Html.Sitecore().Placeholder("PrivateCommunityFAQs")
Line 84:             
Line 85:             

Source File: p:\Inetpub\sitehome\Views\Communities\Resources.cshtml    Line: 83 

Stack Trace: 

[InvalidOperationException: The model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary requires a model item of type 'SLB.Entities.PrivateCommunity.PrivateCommunityFAQModel'.]
   System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) +214
   System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) +155
   System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) +78
   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) +137
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +343

[InvalidOperationException: Error while rendering view: '/Views/Communities/FAQs.cshtml' (model: 'Sitecore.Mvc.Presentation.RenderingModel, Sitecore.Mvc').
]
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +826
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +148
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +75
   (Object , Object[] ) +74
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +193
   Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.PerformRendering.Render(String placeholderName, TextWriter writer, RenderPlaceholderArgs args) +184
   (Object , Object[] ) +74
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +193
   Sitecore.Mvc.Helpers.SitecoreHelper.Placeholder(String placeholderName) +259
   ASP._Page_Views_Communities_Resources_cshtml.Execute() in p:\WebApp\Website\Views\Communities\Resources.cshtml:83
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +253
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +122
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +137
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +343

[InvalidOperationException: Error while rendering view: '/Views/Communities/Resources.cshtml' (model: 'Sitecore.Mvc.Presentation.RenderingModel, Sitecore.Mvc').
]
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +826
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +148
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +75
   (Object , Object[] ) +74
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +193
   Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.PerformRendering.Render(String placeholderName, TextWriter writer, RenderPlaceholderArgs args) +184
   (Object , Object[] ) +74
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +193
   Sitecore.Mvc.Helpers.SitecoreHelper.Placeholder(String placeholderName) +259
   ASP._Page_Views_Shared_Home_cshtml.Execute() in p:\WebApp\Website\Views\Shared\Home.cshtml:269
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +253
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +122
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +137
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +343

[InvalidOperationException: Error while rendering view: '/Views/Shared/Home.cshtml' (model: 'Sitecore.Mvc.Presentation.RenderingModel, Sitecore.Mvc').
]
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +826
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +148
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +75
   (Object , Object[] ) +74
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +193
   Sitecore.Mvc.Presentation.RenderingView.Render(ViewContext viewContext, TextWriter writer) +302
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +375
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +90
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.Async.c__DisplayClass21.b__1e(IAsyncResult asyncResult) +37
1

This standard MVC error says that the strongly typed view /Views/Communities/FAQs.cshtml does not match the model passed to it. Here is a full answer on your question https://community.sitecore.net/developers/f/8/t/109

  • @Vyascheslav: I had tried to implement the solution as suggested above but it has started giving another error as Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index. Description: An unhandled exception occurred. Line 38: if (Sitecore.Context.Database.GetItem(Model.ListEventName[0].Value).ParentID.ToString() ==Constants.PrivateCommunityDocumentsId – Pushpendra Vats Mar 11 '18 at 8:41
  • 1
    @PushpendraVats: You have this error, because your model has not been populated. The model type is correct, but an array here .ListEventName is empty. There are various ways how to populate the custom models in Sitecore MVC. If one uses a controller rendering, then the model is populated in the appropriate action method. If a view rendering is used, then you might inherit the model class from the I/RenderingModel and implement/override the Initialize method to initialize the model. – Vyacheslav Pritykin Mar 11 '18 at 10:34
  • @PushpendraVats: Your original question has been answered. You might accept this answer. – Vyacheslav Pritykin Mar 11 '18 at 19:28
  • @Vyascheslav: I am checking the answer and to implement it and yes, if this resolved the issue, will surely accept the answer. Thanks for all your valuable support and response. – Pushpendra Vats Mar 11 '18 at 20:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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