whenever I use my ash eg Download.ashx? Id = 18 This file gets, but then when it pops up the dialogue dialog it wants me to download the file for download. I fear instead of a file stored in the database (mypdf.pdf says) if you open the file download then this view opens in the studio and does not show anything really useful. What is the reason, I have tried to do it in many browsers and many machines and all this is the same?
Thanks
string id = ctx.Request.QueryString ["id"]; String name = null; String mime = null; SqlConnection con = new SqlConnection (CNN); SqlCommand cmd = New SqlCommand ("DownloadActivityFile", Con?); Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.AddWithValue ("Help", ID); Byte [] afile = null; Try {con.Open (); SqlDataReader Reader = cmd.ExecuteReader (); While (reader.Read ()) {Mime = Reader ["ActivityFileMIME"]. ToString (); Ctx.Response.ContentType = Mime; Afile = (byte []) reader ["activity file"]; Name = reader ["ActivityFileName"]. ToString (); } Ctx.Response.Buffer = false; Ctx.Response.ContentType = Mime; Ctx.Response.AddHeader ("content-type", string.format ("attachment; {0}", name)); Ctx.Response.Clear (); Ctx.Response.BinaryWrite (afile); Ctx.Response.End (); } Hold (exception e) {ctx.Response.Write (e.ToString ()); } Finally {con.Close (); }
you content-split: attachment; File name = \ "{0} \" headers Note file name = , and the quote around the name.
Comments
Post a Comment