I have a technical question for some of you.
Basically i have been testing my application primarily in firefox, I have a download feature in the application where the user can download a file from SQL server database. The problem is that when i download the file in Internet explorer every file will lose its extension apart from the Microsoft files e.g. word, access etc. There are no problems in firefox apart from bitmaps...
here is my code and thank you
//Download attachment file
protected void AttachmentDLBut_Click(object sender, EventArgs e)
{
//set the ID for the selected row
var ID = Request.QueryString["Id"];
using (SqlConnection conn = new SqlConnection("******"))
{
string sql = "SELECT FileType, Filename, Description FROM NetworkEquipment WHERE NetworkEquipmentID = '" + ID + "'";
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
//cmd.Parameters.AddWithValue("@ID", AttachmentDDL.SelectedItem.Value);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
try
{
//if there is an attachment... download it
if (dr.Read())
{
Response.Clear();
Response.ContentType = dr["FileType"].ToString();
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + dr["Filename"].ToString());
Response.BinaryWrite((byte[])dr["Description"]);
Response.End();
conn.Close();
}
}
catch (SqlException sqlex) { MessageBox.Show("Sorry, an unexpected error has occurred while downloading this file. Error: " + sqlex); }
catch (Exception ex) { MessageBox.Show("Sorry, an unexpected error has occurred while downloading this file. Error: " + ex); }
//else nothing happens
}
}
}