从 JavaScript (MVC) 调用 Sitecore 控制器方法

Moo*_*her 3 javascript c# asp.net-mvc sitecore sitecore7.5

我有一个具有功能的控制器ShowEvents(EventCategory eventCategory)。是否可以从客户端 JavaScript 调用此函数?我知道我可以使用Sitecore.Services.Client (SCC)从数据库中检索项目,但是是否可以实际访问方法?也许通过控制器渲染,如果可能的话?

这是我要调用的方法的示例:

public class EventListController : Controller
{
    public ActionResult ShowEvents(EventCategory eventCategory)
    {
        var repository = new EventListRepository();
        var eventPages = repository.GetEvents(eventCategory);
        var eventListViewModel = repository.GetEventListViewModel(eventPages);

        return View("/Some/Path/, eventListViewModel);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是在 Sitecore 7.5 MVC 上

Wes*_*max 5

您可以使用以下格式从客户端发布到控制器

/api/sitecore/{yourcontroller}/{action}在你的情况下,这将作为数据/api/sitecore/eventlist/showevents传递。eventCategory