Search code examples
asp.netc#-4.0sitecore8

Sitecore 8.2 error when adding Placeholder


I am almost completely new to Sitecore and I was about to try out adding a controller rendering to a demo page I am creating.

I have a main page, with a placeholder for the controller rendering. Placeholder is added to the presentation details of my main page item and accepts the rendering.

When I now go to the experience editor and try to add the controller rendering to the page I get this

Error Rendering Controller: SitecoreDemo.Controllers.FoodFinder.PlacesToEatListController, SitecoreDemo. Action: Index: An unhandled exception occurred.
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args)
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.Process(ExceptionArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
   at Sitecore.Mvc.Filters.PipelineBasedRequestFilter.OnException(ExceptionContext exceptionContext)
   at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at Sitecore.Mvc.Controllers.ControllerRunner.ExecuteController(Controller controller)
   at Sitecore.Mvc.Controllers.ControllerRunner.Execute()
   at Sitecore.Mvc.Presentation.ControllerRenderer.Render(TextWriter writer)
   at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)

I think this isn't even the full stacktrace but I only see this little box on the page and I don't know how I could even get to the full exception message...


Solution

  • Problem was caused by putting the view in the wrong place. If returning a view by convention it's always Views\\.cshtml no matter where the controller is located.

    My views were mirroring the namespace structure of the controller which caused ASP.NET MVC to fail finding it by convention (return View(model))