Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you say "a URL which is simply not valid," do you mean a malformed URL, or a correctly-formed URL that doesn't resolve anywhere? I'm pretty sure you mean the former.</p> <p>If you're just looking for well-formedness, I suggest attempting to parse it into a <a href="http://msdn.microsoft.com/en-us/library/system.uri.aspx" rel="nofollow" title="MSDN - Uri Class"><code>Uri</code></a> object:</p> <pre><code>string testUrl = "http://stackoverflow.com/"; Uri goodUri; if (Uri.TryCreate(testUrl, UriKind.Absolute, out goodUri)) { // testUrl == well-formed URI } </code></pre> <p>I use the <code>Uri</code> class a lot, especially before I try to feed it into the SharePoint API for Sites and Webs. I tend to need to hack on it some, either to make a relative URL absolute for my current SP server, or to get parts of the path to resolve to relative locations from the current site.</p> <hr> <p>Just for the sake of completeness, if you ever <strong>are</strong> trying to determine if a URL resolves somewhere or not, you can create an HTTP request and test it:</p> <pre><code>HttpWebRequest req = (HttpWebRequest)WebRequest.Create(goodUri); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); if (resp.StatusCode == HttpStatusCode.OK) { // Received 200 OK -- probably a valid URL } resp.Close(); </code></pre> <p>Of course, the HTTP example above is incredibly, naively, simple. There could be all kinds of responses, or requirements for certain request properties to be set, etc. Review the documentation for <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx" rel="nofollow" title="MSDN - HttpWebRequest Class">HttpWebRequest</a> and <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.aspx" rel="nofollow" title="MSDN - HttpWebResponse Class">HttpWebResponse</a> for more information.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload