Error Rendering Controller: Module 5 - Creating a Breadcrumb Component - eLearning

I am running into an issue which I am stuck at within the eLearning lab. When creating my controller and controller rendering for the breadcrumb I am running into an error:

Error Rendering Controller: events.tac.local.Controllers.Breadcrumb, assemblyname. 
Action: Index: Could not create controller: 'events.tac.local.Controllers.Breadcrumb, assemblyname'. The item being rendered is: '/sitecore/content/Home/Events/Climbing/Climb Mount Everest'. 
The context item is: '/sitecore/content/Home/Events/Climbing/Climb Mount Everest'. 
The current route url is: '{*pathInfo}'. This is the default Sitecore route which is set up in the 'InitializeRoutes' 
processor of the 'initialize' pipeline.

 

I have googled this and tried about everything from checking the versioning and trying to add test controllers to see if they were having the same issue which they were. I have noticed my EventIntro controller rendering is rendering fine but for some reason new controller renderings give me this error. I was hoping that I could get some help over here on the community discussion board.

 

Controller Rendering Screenshot:

 

Breadcrumb Controller Code:

using events.tac.local.Business;
using System.Web.Mvc;

namespace events.tac.local.Controllers
{
    public class BreadcrumbController : Controller
    {

        // GET: Breadcrumb
        public ActionResult Index()
        {
            return View(_builder.Build());
        }

        private readonly BreadcrumbBuilder _builder;

        public BreadcrumbController() : this(new BreadcrumbBuilder()) { }

        public BreadcrumbController(BreadcrumbBuilder builder)
        {
            _builder = builder;
        }

    }
}

 

 

Any help with this would be greatly appreciated.

  • Hi

    In the above image where the controller name is only given breadcrumb , try to give full name with namespace and assembly like

    events.tac.local.Controllers.BreadcrumbController, events.tac.(what is your project/controller assembly name )

    Also check your Index method should not throwing any error, write test method for that
  • In reply to DEBAL SAHA:

    I have changed the controller name in the Breadcrumb rendering but it did not fix the issue. I also went into the index.cshtml for Breadcrumb and just added some text(<p>Testing Breadcrumb Index</p>) and commented out my other code and it is still giving me the same error when previewing. This happens when new controllers, cshtml's, and controller renderings are added for testing purposes as well. So I don't think its an issue of an error on the index method. But I went ahead and tried writing a test for it:

     

    I created a test for this controller method shown below:

    [Fact]
            public void BreadcrumbController_Index_NotReturningError()
            {
                var controller = new BreadcrumbController();
                var result = controller.Index() as ViewResult;
                Assert.Equal("Index", result.ViewName);
            }

     

    After running the test I am getting the following error (Not sure if my test method needs to mock up something for the builder to create a model):

  • In reply to nathan hux:

    Hi

    In this error message it is clear that if you write to call the action method from console application or test application then how Action method will know about what is context , it should be null .

    Anyway did you give proper name and assembly name in the Sitecore controller

    events.tac.local.Controllers.BreadcrumbController, events.tac.(what is your project/controller assembly name ) , save and publish it and run your application

    with w3 process debugger see the controller action method is firing or not
  • In reply to DEBAL SAHA:

    I gave it the proper name as the controller field in the controller rendering. Controller action is not being fired after being attached to the process. It seems like its a routing issue. I have started the whole lab back over and now getting the same results in lab 3 adding the EventIntro(this did not give me an issue before when doing the labs). It is still giving me the same error message when using a controller rendering and when attaching to the process it is not hitting my controller.

  • In reply to nathan hux:

    you told you didn't face this issue before , after creating some new component you are now facing this .

    1) See the namespace and controller name , spell check the name is properly given .
    2)How do you publish you code to inetpub from VS , check the .pdb files are present for that particular assembly .
    3)Check routing , if you need to register the path in your rotue config cs files
    4)check in log files if some error it is throwing or not for this controller rendering .
  • In reply to DEBAL SAHA:

    I changed the name of the controller from the BreadcrumbController to TheBreadcrumbController. This fixed the issue. Sitecore must have implemented a controller already for Breadcrumb with the newest version, not sure.
  • In reply to nathan hux:

    I am also running the same issue.

    I tried the solution posted by nathan hux, but with no success.

     

    Could you please enlighten me?

  • In reply to Pradipta Ghosh:

    Please specified namespace(xxx.xxx.TheBreadcrumb), assembly under controller field.