views:

308

answers:

2

I'm using response object to download word document which is stored in database as a content. It is throwing the following exception :

 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'

I cannot able to view my file.. My code is as follows:

protected void btnResumedload_Click(object sender, EventArgs e)
{
    DataTable dtResumeInfo = new DataTable();

    dtResumeInfo = bc.ConvertByteToDataTable(objservice.getResumeInfo(int.Parse(Session["LoginId"].ToString())));
    if (dtResumeInfo.Rows.Count > 0)
    {
        string doctype = dtResumeInfo.Rows[0]["ContentType"].ToString();
        string docname = dtResumeInfo.Rows[0]["FileName"].ToString();
        //
        try
        {
            Response.Buffer = false;
            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 < binary.GetUpperBound(0) - 1; i = i + ChunkSize)
            {
                if (!Response.IsClientConnected) return;
                if (i + ChunkSize >= 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)
        {
        lblmsg.Visible = true;
        lblmsg.Text = ex.Message;
        }
    }
    else
    {
        lblmsg.Visible = true;
        lblmsg.Text = "No Resume Information Found.";
    }
}
A: 

It appears as though you are using the Response.Headers property which is only supported by the IIS 7.0 integrated pipeline mode. See: IIS6 + HttpModule: This operation requires IIS integrated pipeline mode

Brad
A: 

Hi I am also facing the same problem if you have found the solution, It throws me into the catch block when i come to "Response.End ()"

If anyone gets any solution kindly do tell me. I am stuck and in hurry

Any little help will be greatly appreciated.

Thanks in advance

Regards Sohaib Qazi

Sohaib