我正在尝试编写插件。我开始测试是否可以在索引页面上显示内容。这是我的代码:
//My main plugin class
public IList<string> GetWidgetZones()
{
return new List<string>{ "home_page_before_news" };
}
//My action
[ChildActionOnly]
public ActionResult DisplayLink(string widgetZone, object additionalData = null)
{
_cacheService.Clear();
return View("~/Plugins/Widgets.PartnershipManager/Views/DisplayLink.cshtml");
}
//My view
@{
Layout = "";
}
<a href="#">My first link</a>
我收到以下错误:执行处理程序'System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错。
没有进一步的信息。然而,我尽可能多地匹配NivoSlider的代码。我错过了什么吗?
感谢您的帮助
以下是 GetConfigurationRoute 和 GetDisplayWidgetRoute 方法:
public void GetConfigurationRoute(out string actionName,
out string controllerName,
out RouteValueDictionary routeValues)
{
actionName = "Configure";
controllerName = "PartnershipManager";
routeValues = new RouteValueDictionary()
{
{ "Namespaces", "Nop.Plugin.Widget.PartnershipManager.Controllers" },
{ "area", null }
};
}
public void GetDisplayWidgetRoute(string widgetZone,
out string actionName, out string controllerName,
out RouteValueDictionary routeValues)
{
actionName = "DisplayLink";
controllerName = "PartnershipManager";
routeValues = new RouteValueDictionary()
{
{ "Namespaces", "Nop.Plugin.Widget.PartnershipManager.Controllers" },
{ "area", null },
{ "widgetZone", widgetZone}
};
}
发生错误的地方
public static MvcHtmlString Widget(this HtmlHelper helper,
string widgetZone, object additionalData = null, string area = null)
{
return helper.Action("WidgetsByZone", "Widget",
new { widgetZone = widgetZone,
additionalData = additionalData, area = area });
}