0
votes

View Error Screenshot I am working on the exercise project and cannot seem to add a rendering to a placeholder using the Experience Editor. The site gives a javascript error(albeit, a very vague one) with the following error in the logs:

Nested Exception

Exception: Sitecore.Mvc.Diagnostics.ExceptionWrapper
Message: The controller for path '/' was not found or does not implement IContro
ller.
Source: System.Web.Mvc
   at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestConte
xt requestContext, Type controllerType)
   at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext re
questContext, String controllerName)
   at Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(Reques
tContext requestContext, String controllerName)

I have searched everywhere with no solution. Has anyone else experienced this issue?

EDIT

Model:

 public class FeaturedEvents
    {

        public FeaturedEvents()
        {

        }
        public HtmlString Heading { get; set; }
        public HtmlString Intro { get; set; }

        public HtmlString EventImage  { get; set; }
    }

Controller:

   public class FeaturedEventController : Controller
    {

        public ActionResult Index()
        {
            return View(CreateModel());
        }

        private static FeaturedEvents CreateModel()
        {
            var item = RenderingContext.Current.Rendering.Item;
            var FeaturedEvent = new FeaturedEvents()
            {
                Heading = new HtmlString(FieldRenderer.Render(item, "ContentHeading")),
                EventImage = new HtmlString(FieldRenderer.Render(item, "Event Image", "mw=400")),
                Intro = new HtmlString(FieldRenderer.Render(item, "ContentIntro"))
            };

            return FeaturedEvent;


        }
    }

Route

I am using the default route. I wasn't instructed to change it.

I have created a controller rendering and linked the placeholders as well. But, as soon as I select the rendering for the placeholder in the Experience Editor, it gives me the "An Error occurred" pop up dialog.

Trace Server Error in '/' Application.

The controller for path '/' was not found or does not implement IController.

Description: An unhandled exception occurred.

Exception Details: Sitecore.Mvc.Diagnostics.ExceptionWrapper: The controller for path '/' was not found or does not implement IController.

Source Error:

Line 84:         <div class="container">
Line 85:             <div class="row">
Line 86:                 @Html.Sitecore().Placeholder("FeaturedEvent")
Line 87: 
Line 88:                

Source File: c:\inetpub\wwwroot\ssd.tac.local\Website\Views\TAC\Events\HomeContent.cshtml Line: 86

Stack Trace:

    [ExceptionWrapper: The controller for path '/' was not found or does not implement IController.]
    
    [ControllerCreationException: Could not create controller: 'FeaturedEvent'. 
    The context item is: '/sitecore/content/Events/Home'. 
    The current route url is: '{*pathInfo}'. This is the default Sitecore route which is set up in the 'InitializeRoutes' processor of the 'initialize' pipeline. ]
       Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName) +172
       Sitecore.Mvc.Controllers.ControllerRunner.GetController() +23
       Sitecore.Mvc.Controllers.ControllerRunner.Execute() +43
       Sitecore.Mvc.Presentation.ControllerRenderer.Render(TextWriter writer) +134
       Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +30
       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_TAC_Events_HomeContent_cshtml.Execute() in c:\inetpub\wwwroot\ssd.tac.local\Website\Views\TAC\Events\HomeContent.cshtml:86
       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/TAC/Events/HomeContent.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) +30
       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_TAC_Events_One_Column_cshtml.Execute() in c:\inetpub\wwwroot\ssd.tac.local\Website\Views\TAC\Events\One-Column.cshtml:8
       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/TAC/Events/One-Column.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) +30
       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_TAC_Events_Events_cshtml.Execute() in c:\inetpub\wwwroot\ssd.tac.local\Website\Views\TAC\Events\Events.cshtml:93
       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/TAC/Events/Events.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) +30
       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.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +37
1
Can you please provide the code snippet for the controller and also the route you are using? - Hishaam Namooya
Updated the question good Sir :) - Muhammad Arqum
events.tac.local.Controllers.FeaturedEventController, events.tac.local. I am using fully qualified name here now. I tried the normal way before which is, just use the controller name (minus the "Controller") and Index in the view. - Muhammad Arqum
Please see answer below - Hishaam Namooya

1 Answers

0
votes

I have reproduced the issue on a local instance. I have created the controller rendering in Sitecore as shown below

enter image description here

and update the code accordingly. I have then try to add the rendering on the Experience Editor. This eventually caused the same error.

Solution

The issue was because the dll referencing the Controller was not in the bin folder. So, please make sure that the assembly referencing the Controller is in the bin folder.

Also, even if the dll is in the bin folder, it may be that it is not being overwritten with the new one. You may try to copy and paste the dll into the bin folder.