I have a sql database in which some documents are stored.
The user can enter the application and view a list of his documents.
When I click on the link to the link in the form of a grid of their documents, I get the file from the database, write it to the file system and execute this code.
System.IO.FileInfo file = new System.IO.FileInfo(System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + DocumentName); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.Cookies.Clear(); Response.Cache.SetCacheability(HttpCacheability.Private); Response.CacheControl = "private"; Response.Charset = System.Text.UTF8Encoding.UTF8.WebName; Response.ContentEncoding = System.Text.UTF8Encoding.UTF8; Response.AppendHeader("Content-Length", file.Length.ToString()); Response.AppendHeader("Pragma","cache"); Response.AppendHeader("Expires", "60"); Response.ContentType = GetContentType(file.Extension); Response.AppendHeader("Content-Disposition", "inline; " + "filename=\"" + file.Name + "\"; " + "size=" + file.Length.ToString() + "; " + "creation-date=" + DateTime.Now.ToString("R") + "; " + "modification-date=" + DateTime.Now.ToString("R") + "; " + "read-date=" + DateTime.Now.ToString("R"));
My GetContentType () method simply returns the appropriate file type for the files that I allow "application / pdf, application / msw0rd, etc.
My problem is that when the file is saved, it is the web page itself, not the file from the file system. And in google chrome, it puts the .htm extension at the end of the file name, I think, because it knows it as a web page?
In any case, the first first step would be to get the actual file, not a copy of the webpage in HTML they are sitting on!
Thanks.
John batdorf
source share