Downloading file from server (asp.net) to IE8 Content-Disposition problem with file name

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-04-01T19:08:14Z Indexed on 2010/04/02 1:03 UTC
Read the original article Hit count: 719

Filed under:
|

I am downloading a file from the server/database via aspx page. When using the content-disposition inline the document opens in correct application but the file name is the same as the web page. I want the document to open in say MS Word but with the correct file name. Here is the code that I am using

Response.Buffer = true; Response.ClearContent(); Response.ClearHeaders(); Response.Clear(); Response.ContentType = MimeType(fileName); //function to return the correct MIME TYPE Response.AddHeader("Content-Disposition", @"inline;filename=" + fileName); Response.AddHeader("Content-Length", image.Length.ToString()); Response.BinaryWrite(image); Response.Flush(); Response.Close();

So again, I want the file to open in MS Word with the correct document file name so that the user can properly save/view.

Ideas? thanks

© Stack Overflow or respective owner

Related posts about .NET

Related posts about ASP.NET