I'm currently following the online Sitecore developer formation (official) and i'm unfortunately having troubles to go any further due to a compilation error while trying to preview an item.

Basically, all what i'm trying to do is, binding a component statically, as explained in the lab. In order to do that, i created a controller, a model class and a view :


using Sitecore.Mvc.Presentation;
using Sitecore.Web.UI.WebControls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Website.Models;

namespace Website.Controllers
    public class EventIntroController : Controller
        // GET: EventIntro
        public ActionResult Index()
            return View(CreateModel());
        private static EventIntro CreateModel()
            var item = RenderingContext.Current.ContextItem;
            var eventIntro = new EventIntro()
                Heading = new HtmlString(FieldRenderer.Render(item,"ContentHeading")),
                EventImage = new HtmlString(FieldRenderer.Render(item, "Event Image","mw=400")),
                Highlights = new HtmlString(FieldRenderer.Render(item, "Highlights")),
                Intro = new HtmlString(FieldRenderer.Render(item, "ContentIntro")),
                StartDate = new HtmlString(FieldRenderer.Render(item, "Start Date")),
                Duration = new HtmlString(FieldRenderer.Render(item, "Duration")),
                Difficulty = new HtmlString(FieldRenderer.Render(item, "Difficulty Level")),
            return eventIntro;


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

namespace Website.Models
    public class EventIntro
        public EventIntro() { }
        public HtmlString Heading { get; set; }
        public HtmlString Intro { get; set; }
        public HtmlString Body { get; set; }
        public HtmlString EventImage { get; set; }
        public HtmlString Highlights { get; set; }
        public HtmlString StartDate { get; set; }
        public HtmlString Duration { get; set; }
        public HtmlString Difficulty { get; set; }


@model Website.Models.EventIntro
<!-- [Event Details] -->
<div class="well">
    <p class="text-muted">@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>
<!-- [/Event Details] -->
<!-- [Event Content] -->
<div class="lead">
<div class="article image">
<div class="highlights">
    <h4>Trip @Sitecore.Globalization.Translate.Text("Highlights")</h4>
<!-- [/Event Content] -->

I also created a new rendering in the layout/renderings folder of my Sitecore instance(through Sitcore Rocks). Then in another view, i call it this way:

 @*@Html.Sitecore().Rendering("/sitecore/layout/Renderings/TAC/Events/Event Intro")*@

With the help of Sitecore Rocks, i simply synchronized the folders containing all those files copied above and i get the following error:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'Website' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 26: using System.Web.Optimization; Line 27: using System.Web.Routing; Line 28: using Website; Line 29: Line 30:

line 1 "C:\inetpub\wwwroot\ssd.tac.local\Website\Views\TAC\Events\Layouts\Events.cshtml"

Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\a832d361\1901ffbf\App_Web_events.cshtml.9351e6fa.xdrjtduy.0.cs Line: 28

Thanks in advance for your help

  • 1
    Did you copy the dll to the bin folder? have you checked if it is there? – Vicent Galiana Aug 2 '17 at 15:33
  • 2
    Agreed, it looks like you haven't deployed your assembly to the web application. The dll that your project produces should be in the Website/bin folder. – Nathan Hase Aug 2 '17 at 15:57
  • Thanks a lot, that was my problem... I don't understand why but in the video demo. The guy had not moved that dll to the bin folder of the sitecore instance. Reason why i didn't do it.... – Slrg Aug 2 '17 at 16:07
  • I think you need to use this code to call a controller rendering in razor (cshtml) @Html.Sitecore().Controller("EventInfo", "EventInfo") – Chris Auer Aug 2 '17 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.