I am learning Controller rendering in Sitecore from Here .
I created One simple controller(HelloWorld) and Related View(Index.schtml) . Mapped it(with Name PageContent) in rendering section of Sitecore Explorer... and Add Rendering Item in Home Item in Content Section of Sitecore Explorer.. But When I Browse it, it gives the Error .
The controller for path '/' was not found or does not implement IController.
All the post I have Read are related to Asp .Net MVC ..but I have issue related to Sitecore MVC
Sample.html (Page Content in Sitecore Explorer Rendering Section)
@using Sitecore.Mvc
<html>
<body>
@Html.Sitecore().Placeholder("content")
<p>Today's date is @DateTime.Now.ToShortDateString()</p>
</body>
</html>
Only this Line is giving Problem
@Html.Sitecore().Placeholder("content")
If I remove this line ...It Works fine and page on Browser show date and time
Index.html
<p>Hello from Controller -todays Date is @DateTime.Now.ToString()</p>
Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MVC.Controllers
{
public class HelloWorldController : Controller
{
//
// GET: /HellowWorld/
public ActionResult Index()
{
return View();
}
}
}
This can occur if you have included the default MVC routes, as they override Sitecore's own controller implementation.
Ensure that you have removed the following lines from RouteConfig.cs/Global.cs (depending on MVC version);
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);