Reputation: 752
I use ASP.NET and C# to create file content from binary value
FileStruct currentFile = null;
File file = new File();
currentFile = file.GetFile(FileID, strTableCode);
Response.ContentType = currentFile.ContentType;
Response.OutputStream.Write(currentFile.FileContent, 0, currentFile.FileContent.Length);
Response.AddHeader("content-disposition", string.Format(@"attachment;filename=""{0}""", currentFile.FileName));
Response.Flush();
I put this content in an iframe
with jquery.
After this an open/save dialog is shown.
How can I force to open the file directly without open/save dialog?
Upvotes: 1
Views: 1651
Reputation: 3398
You can't not really anyway.
The way the browser handles the upload is completely up to the browser. (and or user settings)
If you had complete control of client machines there probably would be some browser settings you could force that would open new downloads.
If you had some extra certainties like the browser would always be X you could check out information for a specific browser or write a simple add-on to open files from a certain server. Add that information to you're question.
Upvotes: 2
Reputation: 2748
you cannot force open a file on client machine afterdownload, max you can do is open a new window with something like Response.Redirect("/somePDFFile.pdf"), where somePDFFile.pdf is file on server which client just downloaded
Upvotes: 1