本文整理汇总了C#中System.Uri.ResolveRedirects方法的典型用法代码示例。如果您正苦于以下问题:C# Uri.ResolveRedirects方法的具体用法?C# Uri.ResolveRedirects怎么用?C# Uri.ResolveRedirects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Uri
的用法示例。
在下文中一共展示了Uri.ResolveRedirects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UriExtensions_ResolveRedirects_Facebook
public void UriExtensions_ResolveRedirects_Facebook()
{
Uri uri = new Uri("http://t.co/6VyBZOO");
Uri expected = new Uri("https://www.facebook.com/photo.php?pid=585685&l=588142298a&id=100399403341183");
uri.ResolveRedirects().Should().Be(expected);
}
示例2: UriExtensions_ResolveRedirects_ThrowsOnNonWeb
public void UriExtensions_ResolveRedirects_ThrowsOnNonWeb()
{
Assert.Throws<InvalidOperationException>(() =>
{
Uri uri = new Uri("ftp://www.google.com");
uri.ResolveRedirects();
});
}
示例3: UriExtensions_ResolveRedirects_ErrorHandling
public void UriExtensions_ResolveRedirects_ErrorHandling()
{
Uri uri = new Uri("http://notfound-asdadagasdg.com");
Func<WebException, Uri> map = (x) => null;
uri.ResolveRedirects(map).Should().BeNull();
}
示例4: UriExtensions_ResolveRedirects_TinyUrl
public void UriExtensions_ResolveRedirects_TinyUrl()
{
Uri uri = new Uri("http://tinyurl.com/3lesxnx");
uri.ResolveRedirects().Should().Be(new Uri("http://edition.cnn.com/2011/WORLD/europe/07/18/uk.committee.hearing/"));
}
示例5: UriExtensions_ResolveRedirects_HEADnotAllowed
public void UriExtensions_ResolveRedirects_HEADnotAllowed()
{
Uri uri = new Uri("http://amzn.to/");
Uri expected = new Uri(@"http://www.amazon.com/");
Exception ex = null;
Uri resolved = uri.ResolveRedirects(x => { ex = x; return uri; });
ex.Should().BeNull();
uri.ResolveRedirects().Should().Be(expected);
}