当前位置: 首页>>代码示例>>C#>>正文


C# RouteBase.GetVirtualPath方法代码示例

本文整理汇总了C#中System.Web.Routing.RouteBase.GetVirtualPath方法的典型用法代码示例。如果您正苦于以下问题:C# RouteBase.GetVirtualPath方法的具体用法?C# RouteBase.GetVirtualPath怎么用?C# RouteBase.GetVirtualPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Routing.RouteBase的用法示例。


在下文中一共展示了RouteBase.GetVirtualPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetURL

		internal static string GetURL(RouteBase route, RequestContext context, IResource resource)
		{
			var location = resource.Location;

			var values = new RouteValueDictionary();

			if (location is TypeLocation)
			{
				TypeLocation tl = location as TypeLocation;
				values.Add("assembly", tl.ProxyType.Assembly.GetName().Name);
				values.Add("name", tl.ProxyType.FullName);
			}
			else if (location is EmbeddedLocation)
			{
				EmbeddedLocation el = location as EmbeddedLocation;
				values.Add("assembly", el.Assembly.GetName().Name);
				values.Add("name", el.ResourceName);
			}
			else if (location is VirtualPathLocation)
			{
				VirtualPathLocation vl = location as VirtualPathLocation;
				if (!(resource is IProxyResource))
					return UrlHelper.GenerateContentUrl(vl.VirtualPath, context.HttpContext);
				var p = vl.VirtualPath;
				if (p[0] == '/') p = p.Substring(1);
				values.Add("name", p);
			}
			else if (location is ExternalLocation)
			{
				ExternalLocation el = location as ExternalLocation;
				return el.Uri.ToString();
			}
			else
				throw new Exception("Unknown IResourceLocationType");
			
			var pr = resource as IProxyResource;
			if (pr != null && (pr.CultureSensitive || pr.CultureUISensitive))
			{
				if (pr.CultureSensitive)
					values.Add("culture", CultureInfo.CurrentCulture.LCID.ToString("x"));
				if (pr.CultureUISensitive)
					values.Add("cultureUI", CultureInfo.CurrentUICulture.LCID.ToString("x"));
			}

			values.Add("version", ToHex(resource.Version));

			var virtualPath = route.GetVirtualPath(context, values);
			if (virtualPath == null) throw new Exception("Routing is incomplete.");

			var url = UrlHelper.GenerateContentUrl("~/" + virtualPath.VirtualPath, context.HttpContext);
			return url;
		}
开发者ID:sebmarkbage,项目名称:calyptus.resourcemanager,代码行数:52,代码来源:RoutingResourceURLFactory.cs

示例2: GetRoutedUrl

        private string GetRoutedUrl(RouteBase route, RouteValueDictionary routeValues, RequestContext requestContext)
        {
            string routedVirtualPath = route.GetVirtualPath(requestContext, routeValues).VirtualPath; // i.e. "AllenISD"

            // Get the base URL with the trailing slash, if it exists
            string urlBase = requestUrlBaseProvider.GetRequestUrlBase(requestContext.HttpContext.Request);

            // Construct the URL that has been regenerated (i.e. a request for https://app/AllenISD/Overview will be shortened 
            // to https://app/AllenISD if "Overview" is defaulted, thereby making it possible to match with generated URLs on 
            // the menu items for determining correct menu selection)
            var returnValue = (new Uri(urlBase + routedVirtualPath)).AbsolutePath;

            return returnValue;
        }
开发者ID:sybrix,项目名称:EdFi-App,代码行数:14,代码来源:PreviousNextController.cs


注:本文中的System.Web.Routing.RouteBase.GetVirtualPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。