I have a relative or absolute url in a string. First I must know if it is absolute or relative. How should I do it? Then I want to determine if the domain URL is in the permissions list.
Here is my list of permissions, for example:
string[] Allowed = { "google.com", "yahoo.com", "espn.com" }
As soon as I know if its relative or absolute, its pretty simple, I think:
if (Url.IsAbsolute) { if (!Url.Contains("://")) Url = "http://" + Url; return Allowed.Contains(new Uri(Url).Host); } else //Is Relative { return true; }
c # url parsing
Mark Oct 23 2018-10-10 at 10:46
source share