本文整理汇总了C#中System.Web.Routing.RouteData.ApplyCurrentModel方法的典型用法代码示例。如果您正苦于以下问题:C# RouteData.ApplyCurrentModel方法的具体用法?C# RouteData.ApplyCurrentModel怎么用?C# RouteData.ApplyCurrentModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Routing.RouteData
的用法示例。
在下文中一共展示了RouteData.ApplyCurrentModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRouteData
/// <summary>
/// Gets the route data.
/// </summary>
/// <param name="httpContextBase">The HTTP context base.</param>
/// <returns></returns>
public override RouteData GetRouteData(HttpContextBase httpContextBase) {
if (httpContextBase.Request.CurrentExecutionFilePath.StartsWith("/dashboard", StringComparison.InvariantCultureIgnoreCase))
return null;
var routeData = new RouteData(this, _routeHandler);
foreach (var defaultPair in _innerRoute.Defaults)
routeData.Values[defaultPair.Key] = defaultPair.Value;
foreach (var tokenPair in _innerRoute.DataTokens)
routeData.DataTokens[tokenPair.Key] = tokenPair.Value;
// get the virtual path of the request
var virtualPath = httpContextBase.Request.CurrentExecutionFilePath.TrimStart(new[] {'/'});
//var virtualPath = httpContextBase.Request.AppRelativeCurrentExecutionFilePath;
// try to resolve the current item
var pathData = _pathResolver.ResolvePath(virtualPath);
// Abort and proceed to other routes in the route table
if (pathData == null) {
return null;
}
routeData.ApplyCurrentModel(pathData.Controller, pathData.Action, pathData.CurrentPageModel);
return routeData;
}
示例2: GetRouteData
/// <summary>
/// When overridden in a derived class, returns route information about the request.
/// </summary>
/// <param name="httpContext">An object that encapsulates information about the HTTP request.</param>
/// <returns>
/// An object that contains the values from the route definition if the route matches the current request, or null if the route does not match the request.
/// </returns>
public override RouteData GetRouteData(System.Web.HttpContextBase httpContext)
{
// get the virtual path of the request
var virtualPath = httpContext.Request.CurrentExecutionFilePath;
// abort if the virtual path does not contain dashboard
if (!IsDashboardRoute(virtualPath)) {
return null;
}
// try to resolve the current item
var pathData = _pathResolver.ResolvePath(virtualPath.Replace("/dashboard/content", "").TrimStart(new[] {'/'}));
var routeData = new RouteData(this, _routeHandler);
foreach (var defaultPair in _innerRoute.Defaults)
routeData.Values[defaultPair.Key] = defaultPair.Value;
foreach (var tokenPair in _innerRoute.DataTokens)
routeData.DataTokens[tokenPair.Key] = tokenPair.Value;
// Abort and proceed to other routes in the route table
if (pathData == null) {
return null;
}
routeData.ApplyCurrentModel(pathData.Controller, pathData.Action, pathData.CurrentPageModel);
return routeData;
}
示例3: GetRouteData
/// <summary>
/// Gets the route data.
/// </summary>
/// <param name="httpContextBase">The HTTP context base.</param>
/// <returns></returns>
public override RouteData GetRouteData(HttpContextBase httpContextBase)
{
if (new Regex("^https?://" + SubDomain).IsMatch(httpContextBase.Request.Url.AbsoluteUri)) {
return null;
}
var routeData = new RouteData(this, _routeHandler);
// get the virtual path of the request
var virtualPath = httpContextBase.Request.CurrentExecutionFilePath.TrimStart(new[] { '/' });
//var virtualPath = httpContextBase.Request.AppRelativeCurrentExecutionFilePath;
// try to resolve the current item
var pathData = this.PathResolver.ResolvePath(routeData, virtualPath);
// Abort and proceed to other routes in the route table
if (pathData == null) {
return null;
}
routeData.ApplyCurrentModel(pathData.Controller, pathData.Action, pathData.CurrentPageModel);
return routeData;
}