title: How to properly validate file from user and detect extension change?
body: <p>I have this code</p>
  
  <pre><code>public bool IsImage(HttpPostedFileBase file)
  {
      var contentType = file.ContentType.Split("/")(0).ToLower() == "image"
  
      if (contentType != "image")
      {
           return false;
      }
  
      return true;
  }
  </code></pre>
  
  <p>however if the user rename an <code>.exe</code> file to <code>.jpg</code>, it will still think it is a valid image file. How to prevent this?</p>