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


C# Uri.MakeAbsolute方法代码示例

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


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

示例1: Page_Load

		protected void Page_Load(object sender, EventArgs e)
		{
			//提供在获取到OpenID时的转发页面,主要用于脚本间的跨域访问
			Uri bridgeRelativeUrl = new Uri(this.ResolveUrl("OpenIDBridge.aspx"), UriKind.Relative);

			Uri bridgeUri = bridgeRelativeUrl.MakeAbsolute(this.Request.Url);

			QQAuthorizationCodeRequestParams requestParams =
				new QQAuthorizationCodeRequestParams(QQConnectionSettings.GetConfig().LoginCallback.ToString(),
					bridgeUri.ToString());

			Response.Redirect(requestParams.ToUrl());
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:13,代码来源:QQLogin.aspx.cs

示例2: ParseQueryStringToDictionary

 private static IDictionary<string, string> ParseQueryStringToDictionary(Uri uri)
 {
     if (uri == null)
         return EmptyUriDictionary;
     var dictionary = new Dictionary<string, string>(StringComparer.Ordinal);
     foreach (string url in uri.MakeAbsolute()
         .GetComponents(UriComponents.Query, UriFormat.SafeUnescaped)
         .Split("&".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
     {
         int length = url.IndexOf("=", StringComparison.Ordinal);
         if (length == -1)
             dictionary.Add(UrlDecode(url), string.Empty);
         else
             dictionary.Add(UrlDecode(url.Substring(0, length)), UrlDecode(url.Substring(length + 1)));
     }
     return dictionary;
 }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:17,代码来源:UriUtils.cs

示例3: GetNodeIdByUrl

		/// <summary>
		/// Gets the node Id by URL.
		/// </summary>
		/// <param name="url">The URL to get the XML node from.</param>
		/// <returns>Returns the node Id.</returns>
		/// <remarks>
		/// Thanks to Jonas Eriksson http://our.umbraco.org/member/4853
		/// </remarks>
		public static int GetNodeIdByUrl(string url)
		{
			var uri = new Uri(url, UriKind.RelativeOrAbsolute);
			if (!uri.IsAbsoluteUri)
				uri = uri.MakeAbsolute(Umbraco.Web.UmbracoContext.Current.CleanedUmbracoUrl);
			uri = Umbraco.Web.UriUtility.UriToUmbraco(uri);

			var docreq = new Umbraco.Web.Routing.PublishedContentRequest(uri, Umbraco.Web.UmbracoContext.Current.RoutingContext);
			var builder = new Umbraco.Web.Routing.PublishedContentRequestBuilder(docreq);
			builder.LookupDomain();
			builder.LookupDocument();
			return docreq.HasNode ? docreq.DocumentId : uQuery.RootNodeId;
		}
开发者ID:elrute,项目名称:Triphulcas,代码行数:21,代码来源:uQuery-Nodes.cs

示例4: MakeAbsolute

 public void MakeAbsolute(string input, string reference, string expected)
 {
     var source = new Uri(input, UriKind.Relative);
     var absolute = new Uri(reference);
     var output = source.MakeAbsolute(absolute);
     Assert.AreEqual(expected, output.ToString());
 }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:7,代码来源:UriExtensionsTests.cs

示例5: GetNodeIdByUrl

		/// <summary>
		/// Gets the node Id by URL.
		/// </summary>
		/// <param name="url">The URL to get the XML node from.</param>
		/// <returns>Returns the node Id.</returns>
		/// <remarks>
		/// <para>Thanks to Jonas Eriksson http://our.umbraco.org/member/4853 </para>
		/// <para>Just runs lookups to find the document, does not follow internal redirects, 404 handlers,
		/// page access verification, wildcard domains -- nothing.</para>
		/// </remarks>
		public static int GetNodeIdByUrl(string url)
		{
			var uri = new Uri(url, UriKind.RelativeOrAbsolute);
			if (!uri.IsAbsoluteUri)
				uri = uri.MakeAbsolute(Umbraco.Web.UmbracoContext.Current.CleanedUmbracoUrl);
			uri = Umbraco.Web.UriUtility.UriToUmbraco(uri);

			var pcr = new Umbraco.Web.Routing.PublishedContentRequest(uri, Umbraco.Web.UmbracoContext.Current.RoutingContext);
			// partially prepare the request: do _not_ follow redirects, handle 404, nothing - just find a content
			pcr.Engine.FindDomain();
			pcr.Engine.FindPublishedContent();
			return pcr.HasPublishedContent ? pcr.PublishedContent.Id : uQuery.RootNodeId;
		}
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:23,代码来源:uQuery-Nodes.cs

示例6: MakeDestinationUrlAbsolute

		/// <summary>
		/// 如果目标路径是相对地址,则转换为和baseUri相关的绝对地址
		/// </summary>
		/// <param name="baseUri"></param>
		/// <returns></returns>
		public string MakeDestinationUrlAbsolute(Uri baseUri)
		{
			Uri destUri = new Uri(this.DestinationUrl, UriKind.RelativeOrAbsolute);

			if (destUri.IsAbsoluteUri == false)
			{
				baseUri.NullCheck("baseUri");

				this.DestinationUrl = destUri.MakeAbsolute(baseUri).ToString();
			}

			return this.DestinationUrl;
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:18,代码来源:AccessTicket.cs

示例7: MatchesUri

 public static bool MatchesUri(Uri navigationUri)
 {
     return navigationUri.MakeAbsolute().AbsolutePath ==
         BaseNavigationUri.MakeAbsolute().AbsolutePath;
 }
开发者ID:richardszalay,项目名称:build-scout,代码行数:5,代码来源:JobTile.cs

示例8: MakeRootRelativeUriToToRelativePathTest

		public void MakeRootRelativeUriToToRelativePathTest()
		{
			Uri target = new Uri("/test.aspx", UriKind.RelativeOrAbsolute);
			Uri refUri = new Uri("/foo/bar.aspx", UriKind.RelativeOrAbsolute);

			Assert.AreEqual("/test.aspx", target.MakeAbsolute(refUri).ToString());
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:7,代码来源:UriTest.cs

示例9: MakeRelativeUriWithBackDirToToAbsolutePathTest

		public void MakeRelativeUriWithBackDirToToAbsolutePathTest()
		{
			Uri target = new Uri("../test.aspx", UriKind.RelativeOrAbsolute);
			Uri refUri = new Uri("http://www.sina.com.cn/foo/bar.aspx");

			Assert.AreEqual("http://www.sina.com.cn/test.aspx", target.MakeAbsolute(refUri).ToString());
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:7,代码来源:UriTest.cs

示例10: MakeAbsoluteUriToAnthorAbsolutePathTest

		public void MakeAbsoluteUriToAnthorAbsolutePathTest()
		{
			Uri target = new Uri("http://www.baidu.com/test.aspx");
			Uri refUri = new Uri("http://www.sina.com.cn/foo/bar.aspx");

			Assert.AreEqual("http://www.sina.com.cn/test.aspx", target.MakeAbsolute(refUri).ToString());
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:7,代码来源:UriTest.cs


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