當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。