title: Which content type should use for all types of files to download file in asp.net?
body: <p>I have functionality to download file in asp.net. I have bytes, filename and size. I have tried by following way but whenever I open file, it doesn't open correctly. If it's jpg or png file, it doesn't display picture.</p>
  
  <p>Here is my code on button click:</p>
  
  <pre><code>byte[] bytes = Encoding.ASCII.GetBytes(getStringFromServer());
  Response.Clear();
  Response.Buffer = true;
  Response.Charset = "";
  Response.Cache.SetCacheability(HttpCacheability.NoCache);
  Response.ContentType = "application/octet-stream";
  Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
  Response.BinaryWrite(bytes);
  Response.Flush();
  Response.End();
  </code></pre>
  
  <p>I have read somewhere that I need to specify ContentType. But in my case, file can be of any type.</p>
  
  <p>Can anybody please guide me appropriate way?</p>