using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace bajaWare
{
    public partial class frmDescarga : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            string strNombre = Request.QueryString["nombre"].ToString();
            string strTipo = Request.QueryString["tipo"].ToString();

            System.IO.MemoryStream mstream = (System.IO.MemoryStream)Session["GetData"];
            //Convert the memorystream to an array of bytes.
            byte[] byteArray = mstream.ToArray();
            String FileName;
            FileName = strNombre;//dllLayout.SelectedItem.Text;
            //Clean up the memory stream
            mstream.Flush();
            mstream.Close();

            // Clear all content output from the buffer stream
            Response.Clear();
            // Add a HTTP header to the output stream that specifies the default filename
            // for the browser's download dialog
            Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + strTipo);
            // Add a HTTP header to the output stream that contains the 
            // content length(File Size). This lets the browser know how much data is being transfered
            Response.AddHeader("Content-Length", byteArray.Length.ToString());
            // Set the HTTP MIME type of the output stream
            Response.ContentType = "text/plain";
            //Write the data out to the client.
            Response.BinaryWrite(byteArray);

        }
    }
}