• Not Answered

Error Rendering Controller

I have run into a bit of an issue while taking this course.  In going through Module 3: Creating a Component Lab, I get an exception message when viewing the Event Details page. See the error below:

I have gone through this lab multiple times, even beginning from scratch a couple of times and whenever I get to this step I encounter the same error. I have googled for an answer but no solution out there seems to address the issue. See my setup below.

 

I have ensured there are no typos in the Controller Rendering side

I have ensured I don’t have any typos in the code side:

 

EventIntro Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Sitecore.Web.UI.WebControls;
using Sitecore.Mvc.Presentation;
using events.tac.local.Models;

namespace events.tac.local.Controllers
{
    public class EventIntroController : Controller
    {
        // GET: EventIntro
        public ActionResult Index()
        {
            return View(CreateModel());
        }

        public static EventIntro CreateModel()
        {
            var item = RenderingContext.Current.ContextItem;
            return new EventIntro()
            {
                ContentHeading = new HtmlString(FieldRenderer.Render(item,"ContentHeading")),
                ContentBody = new HtmlString(FieldRenderer.Render(item, "ContentBody")),
                EventImage = new HtmlString(FieldRenderer.Render(item, "EventImage","mw=400")),
                Highlights = new HtmlString(FieldRenderer.Render(item, "Highlights")),
                ContentIntro = new HtmlString(FieldRenderer.Render(item, "ContentIntro")),
                StartDate = new HtmlString(FieldRenderer.Render(item, "StartDate")),
                Duration = new HtmlString(FieldRenderer.Render(item, "Duration")),
                DifficultyLevel = new HtmlString(FieldRenderer.Render(item,"DifficultyLevel"))
            };
        }
    }
}

EventIntro Model

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace events.tac.local.Models
{
    public class EventIntro
    {
        public HtmlString ContentHeading { get; set; }
        public HtmlString ContentIntro { get; set; }
        public HtmlString ContentBody { get; set; }
        public HtmlString EventImage { get; set; }
        public HtmlString Highlights { get; set; }
        public HtmlString StartDate { get; set; }
        public HtmlString Duration { get; set; }
        public HtmlString DifficultyLevel { get; set; }
    }
}

EventIntro.View

@model events.tac.local.Models.EventIntro
<header>
    <h1>@Model.ContentHeading</h1>
</header>
<!-- [Event Details] -->
<div class="well">
    <p class="text-muted">Start Date: @Model.StartDate</p>
    <p class="text-muted">Duration: @Model.Duration</p>
    <span class="text-muted">Difficulty:</span>
    <div class="difficulty-circle">
        <input type="radio" name="group-2" id=group-2-0 value=10 />
        <label class=red for=group-2-0></label>
        <input type="radio" checked="checked" name="group-2" id=group-2-1 value=9 />
        <label class=red for=group-2-1></label>
        <input type="radio" name="group-2" id=group-2-2 value=8 />
        <label class=red for=group-2-2></label>
        <input type="radio" name="group-2" id=group-2-3 value=7 />
        <label class=yellow for=group-2-3></label>
        <input type="radio" name="group-2" id=group-2-4 value=6 />
        <label class=yellow for=group-2-4></label>
        <input type="radio" name="group-2" id=group-2-5 value=5 />
        <label class=yellow for=group-2-5></label>
        <input type="radio" name="group-2" id=group-2-6 value=4 />
        <label class=green for=group-2-6></label>
        <input type="radio" name="group-2" id=group-2-7 value=3 />
        <label class=green for=group-2-7></label>
        <input type="radio" name="group-2" id=group-2-8 value=2 />
        <label class=green for=group-2-8></label>
        <input type="radio" name="group-2" id=group-2-9 value=1 />
        <label class=green for=group-2-9></label>
    </div>
</div>
<!-- [/Event Details] -->
<!-- [Event Content] -->
<div class="lead">
    @Model.ContentBody
</div>
<div class="article image">
    @Model.EventImage
</div>
<div class="highlights">
    <h4>Trip Highlights</h4>
    @Model.Highlights
</div>
<!-- [/Event Content] -->

Events View (Portion where the Rendering is called)

                            <!-- [Event Info] -->
                            @Html.Sitecore().Rendering("/sitecore/layout/Renderings/TAC/Events/EventIntro")
                            <!-- [/Event Info] -->

 

I would greatly appreciate your help on this as I have continued the training without being able to validate my work because of this issue.

4 Replies

  • I just compared all your code to my own solution and it all looks right... Can you confirm that your EventIntro rendering is a Controller Rendering, or try maybe creating EventIntro2, use it for your static rendering instead, and deploy the entire solution just for kicks?

  • In reply to Allan Rogers:

    - Confirmed that EventIntro is a Controller Rendering object
    - Created another Controller Rendering called EventIntro2 and changed the reference in the view to point to it. Same results
    - Created another Controller called Default with the same implementation as EventIntro and changed the EventIntro Controller Rendering to use it instead. Same result

    Could this be a routing issue? The other exception "Inner Exception: The controller for path '/' was not found or does not implement IController would seem to indicate something path related to me.
  • In reply to Danny Acuna:

    An update on this. I tried adding an Area called TAC just to see if I saw a different message or perhaps find a solution to the issue but it did not change the anything.
  • In reply to Danny Acuna:

    I was watching some youtube video and also saw someone with a controller path error by chance. In their case they had to remove the word Controller from their Controller Action field on the Controller Rendering. Your screenshot doesnt show that obviously, but maybe you want to test around with adding/removing the word Controller from the related files/items. Sorry I cant help more, I would suggest contacting support. Good luck