无法将类型为“ Umbraco.Web.Models.RenderModel”的对象转换为类型为“ Umbraco.Web.Routing.PublishedContentRequest”的Umbraco劫持

时间:2018-08-06 07:39:04

标签: c# asp.net umbraco umbraco7 umbraco-blog

我正在使用Umbraco劫持控制器,即RenderMvcController。就我而言,我想使用umbraco.TypedSearch方法。由于劫持控制器,我制作了一个方法createRenderModel(IPublishedContent)。这是该方法的实现。

private RenderModel CreateRenderModel(IPublishedContent content)
    {
        var model = new RenderModel(content, CultureInfo.CurrentUICulture);
        RouteData.DataTokens["umbraco-doc-request"] = model;
        RouteData.DataTokens["umbraco"] = model;
        return model;
    }

我的控制器的动作结果代码是

public ActionResult Web(RenderModel model, string search)
    {
        var region = CookieHelpers.GetCurrentRegion();
        var regionpage = UmbracoHelpers.GetSelectableCountry(region);
        var pathid = string.Empty;
        if(regionpage!=null)
        {
            pathid = regionpage.Id.ToString();
        }
        var viewModel = CreateRenderModel(regionpage);
        //Here i Got Error
var a = currentNode.TypedSearch(search).Where(x => x.DocumentTypeAlias == "retailer" && x.Path.Contains(pathid)).ToList();

        return View();
    }

0 个答案:

没有答案