本文整理汇总了C#中ContentItem.ClosestPage方法的典型用法代码示例。如果您正苦于以下问题:C# ContentItem.ClosestPage方法的具体用法?C# ContentItem.ClosestPage怎么用?C# ContentItem.ClosestPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentItem
的用法示例。
在下文中一共展示了ContentItem.ClosestPage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHtmlHelper
private static HtmlHelper CreateHtmlHelper(ContentItem item, TextWriter writer)
{
var httpContext = new HttpContextWrapper(HttpContext.Current);
var routeData = new RouteData();
RouteExtensions.ApplyCurrentPath(routeData, "WebForms", "Index", new PathData(item.ClosestPage(), item));
return new HtmlHelper(
new ViewContext(
new ControllerContext() { HttpContext = httpContext, RequestContext = new RequestContext(httpContext, routeData), RouteData = routeData },
new WebFormView(HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath),
new ViewDataDictionary(),
new TempDataDictionary(),
writer),
new ViewPage(),
RouteTable.Routes);
}
示例2: GetRouteData
private RouteData GetRouteData(RequestContext requestContext, ContentItem item, string controllerName)
{
var data = new RouteData();
data.Values[ContentRoute.ControllerKey] = controllerName;
data.Values[ContentRoute.ActionKey] = "Index";
data.Values[ContentRoute.ContentItemKey] = item.ID;
// retrieve the virtual path so we can figure out if this item is routed through an area
var vpd = routes.GetVirtualPath(requestContext, data.Values);
if (vpd == null)
throw new InvalidOperationException("Unable to render " + item + " (" + data.Values.ToQueryString() + " did not match any route)");
data.Values["area"] = vpd.DataTokens["area"];
data.Route = vpd.Route;
data.ApplyCurrentPath(new PathData(item.ClosestPage(), item));
return data;
}