本文整理汇总了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());
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例7: MatchesUri
public static bool MatchesUri(Uri navigationUri)
{
return navigationUri.MakeAbsolute().AbsolutePath ==
BaseNavigationUri.MakeAbsolute().AbsolutePath;
}
示例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());
}
示例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());
}
示例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());
}