title: How to download word document stored in database as content data in sql server?
body: <p>How to download a word document which is stored in database, sql server as a content data through C#? </p>
  
  <p>This is my Code I'm using:</p>
  
  <pre><code>string doctype = dtResumeInfo.Rows[0]["ContentType"].ToString();
              string docname = dtResumeInfo.Rows[0]["FileName"].ToString();
              //
              try
              {
                  Response.Buffer = false;
                  Response.ClearContent();
                  Response.ClearHeaders();
                  Response.ContentType = doctype;
                  Response.AddHeader("Content-Disposition",
                           "attachment; filename=" + docname);
                  //
                  //Code for streaming the object while writing
                  const int ChunkSize = 1024;
                  byte[] buffer = new byte[ChunkSize];
                  byte[] binary = (dtResumeInfo.Rows[0]["ContentData"]) as byte[];
                  MemoryStream ms = new MemoryStream(binary);
                  int SizeToWrite = ChunkSize;
  
                  for (int i = 0; i &lt; binary.GetUpperBound(0) - 1; i = i + ChunkSize)
                  {
                      if (!Response.IsClientConnected) return;
                      if (i + ChunkSize &gt;= binary.Length)
                          SizeToWrite = binary.Length - i;
                      byte[] chunk = new byte[SizeToWrite];
                      ms.Read(chunk, 0, SizeToWrite);
                      Response.BinaryWrite(chunk);
                      Response.Flush();
                  }
                  Response.Close();
              }
              catch (Exception ex)
              {
  
              }
  </code></pre>
  
  <p>But, it is showing the following error:</p>
  
  <pre><code>SubStatusCode 'Response.SubStatusCode' threw an exception of type 'System.PlatformNotSupportedException'
   base {"This operation requires IIS integrated pipeline mode."} System.NotSupportedException  {System.PlatformNotSupportedException}
   Headers 'Response.Headers' threw an exception of type 'System.PlatformNotSupportedException'
  </code></pre>
  
  <p>My IIS version is 6.0 where I published. Donwloading word document can be done only in IIS 7. So, this is the cause of the error. Is there any other way to overcome this problem? Any other code will support lower version?? Plz, help me. (Sorry for long message.. )</p>