I am developing Speak app in Sitecore which needs AJAX calls to collect some data.
I’ve developed simple controller in my Sitecore MVC project, but can’t get access to the controller.
Here is what I did I try:
Registered route table ref. https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0700677
using System.Web.Mvc;
using System.Web.Routing;
using Sitecore.Pipelines;
namespace Sitecore.Test.App.Pipelines
{
public class RegisterRoutes
{
public virtual void Process(PipelineArgs args)
{
RouteTable.Routes.MapRoute("CustomRoute", "some/route/{controller}/{action}/{id}");
}
}
}
appended configuration:
<pipelines>
<initialize>
<processor type="Sitecore.Test.App.Pipelines.RegisterRoutes, Sitecore.Test.App"
patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
</initialize>
</pipelines>
Created Controller:
using System.Web.Mvc;
namespace Sitecore.Avilinga.Connector.Controllers
{
public class ProjectController : Controller
{
[HttpGet]
public JsonResult GetItem(string id)
{
string name = "Tom";
return Json(name, JsonRequestBehavior.AllowGet);
}
}
}
When I deploy and try to open the url
https://sitecoresc.dev.local/some/route/project/getitem/1
I get this
Server Error in ‘/’ Application.
The controller for path ‘/some/route/project/getitem/1’ was not found or does not implement IController.
[ControllerCreationException: Could not create controller: ‘project’…]
What I am missing?
Kiryl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.