'This operation is not supported for a relative URI
I have an hyperlink that throw the exception : "This operation is not supported for a relative URI"
Code:
Process.Start(e.Uri.AbsolutePath);
I want to enforce it to open the browser even if the uri is something like : "1aabbb3"
How can I do that ?
Solution 1:[1]
System.Diagnostics.Process.Start("iexplore"); should open a very specific browser to it's home page.
Solution 2:[2]
You can try using Uri.OriginalString
Process.Start("iexplore.exe", e.Uri.OriginalString);
Edited to reflect clarification in comment.
Solution 3:[3]
Solution1: check IsAbsoluteUri and use OriginalString
if (uri.IsAbsoluteUri)
Console.WriteLine("Url:{0}", uri.AbsoluteUri);
else
Console.WriteLine("Url:{0}", uri.OriginalString);
Solution2: define the url protocol
url = "http://someRelativeUrl";
uri = new Uri(url);
Console.WriteLine("Url:{0}", uri.AbsoluteUri);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Noel Abrahams |
| Solution 2 | |
| Solution 3 | mqueirozcorreia |
