title: Determine if Absolute or Relative URL
body: <p>I have a relative or absolute url in a string.  I first need to know whether it is absolute or relative.  How do I do this?  I then want to determine if the domain of the url is in an allow list.</p>
  
  <p>Here is my allow list, as an example:</p>
  
  <pre><code>string[] Allowed =
  {
     "google.com",
     "yahoo.com",
     "espn.com"
  }
  </code></pre>
  
  <p>Once I know whether its relative or absolute, its fairly simple I think:</p>
  
  <pre><code>if (Url.IsAbsolute)
  {
      if (!Url.Contains("://"))
          Url = "http://" + Url;
  
      return Allowed.Contains(new Uri(Url).Host);
  }
  else //Is Relative
  {
      return true;
  }
  </code></pre>