本文整理汇总了C#中ISiteMapNode.GetRouteData方法的典型用法代码示例。如果您正苦于以下问题:C# ISiteMapNode.GetRouteData方法的具体用法?C# ISiteMapNode.GetRouteData怎么用?C# ISiteMapNode.GetRouteData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISiteMapNode
的用法示例。
在下文中一共展示了ISiteMapNode.GetRouteData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindRoutesForNode
protected virtual RouteData FindRoutesForNode(ISiteMapNode node, HttpContextBase httpContext)
{
RouteData routeData = null;
// Create a Uri for the current node. If we have an absolute URL,
// it will be used instead of the baseUri.
var nodeUri = new Uri(httpContext.Request.Url, node.Url);
// Create a TextWriter with null stream as a backing stream
// which doesn't consume resources
using (var nullWriter = new StreamWriter(Stream.Null))
{
// Create a new HTTP context using the node's URL instead of the current one.
var nodeHttpContext = this.mvcContextFactory.CreateHttpContext(node, nodeUri, nullWriter);
// Find routes for the sitemap node's URL using the new HTTP context
routeData = node.GetRouteData(nodeHttpContext);
}
return routeData;
}
示例2: FindRoutesForNode
protected virtual RouteData FindRoutesForNode(ISiteMapNode node, string originalPath, HttpContextBase httpContext)
{
var routes = mvcContextFactory.GetRoutes();
var originalRoutes = routes.GetRouteData(httpContext);
var nodeUrl = node.Url;
httpContext.RewritePath(nodeUrl, true);
RouteData routeData = node.GetRouteData(httpContext);
if (routeData != null)
{
foreach (var routeValue in node.RouteValues)
{
routeData.Values[routeValue.Key] = routeValue.Value;
}
if (originalRoutes != null && (!routeData.Route.Equals(originalRoutes.Route) || originalPath != nodeUrl || node.Area == String.Empty))
{
routeData.DataTokens.Remove("area");
//routeData.DataTokens.Remove("Namespaces");
//routeData.Values.Remove("area");
}
}
return routeData;
}