title: Invoke Url to check content type?
body: <p>I need to check if the url content type is pdf or not? I have a working code however i was wondering what's the best way to check from what i have. I don't need to display the pdf, just need to check if the content type is pdf or not?
  <strong>Note: This method will be called multiple times with different url, so i am not sure if i need to close the response or not.</strong></p>
  
  <p>here is my code.</p>
  
  <pre><code>private bool IsValid(string url)
  {
      bool isValid = false;
      var request = (HttpWebRequest)WebRequest.Create(url);
      var response = (HttpWebResponse)request.GetResponse();
      if(response.StatusCode == HttpStatusCode.OK &amp;&amp; response.ContentType == "application/pdf")
      {
         isValid = true;
      }
      response.Close();
    return isValid;
  }
  </code></pre>