Solved

Unable to download files from application in Mozilla firefox

Posted on 2009-07-11
2
1,644 Views
Last Modified: 2013-12-07
We have a link in one of our web pages. On click of this link we open a pop-up window in which we display all documents that a user has uploaded to our application. We are opening the pop-up window as a model dialog using the function 'window.showModalDialog()' in javascript.

We have a download link for each attachment uploaded. The download link triggers a post-back event which downloads a file from the server. During the download, the 'save-as' dialog box opens.

Now the problem is, during the execution of above scenario in Mozilla Firefox browser, once the 'save as' dialog box opens (as shown in the attachment), the whole dialog box freezes. The 'save-as' or 'Cancel' buttons does not work. The 'save as' dialog box can be closed only using the window close (X) button. As a result, we are not able to download the file which we intend to. This problem does not occur with the Internet Explorer browser and so we are able to download the file. We are facing this problem only with Mozilla Firefox.

This 'save as' dialog box also works perfectly if the window with all attachments is opened as an ordinary window (using the function 'window.open()') instead of the modal dialog.

I have attached code and word document with code.

Thanks.
if (!IsPostBack)
            {
                if (Request.QueryString.ToString() == "instructions")
                {
                    pnlInstructions.Visible = true;
                }
                else
                {
                    root = System.Configuration.ConfigurationSettings.AppSettings["attachement_root"].ToString();
                    filepath = Session["filepath"].ToString();
                    filename = Session["filename"].ToString();
                    string[] s_arr = filepath.Split(new char[] { '\\' });
                    filename = s_arr[s_arr.Length - 1];//filepath.Substring(filepath.LastIndexOf("\\"), filepath.Length-filepath.LastIndexOf("\\"));
                    if (filepath != null)
                    {
                        if (File.Exists(filepath))
                        {
                            Response.ClearHeaders();
                            Response.Buffer = true;
                            Response.ClearContent();
                            Response.Clear();
 
 
                            FileInfo DownloadFileInfo = new FileInfo(filepath);
                            string Ext = DownloadFileInfo.Extension;
 
                            if (Ext != null)
                            {
                                Ext = Ext.ToLower();
                            }
 
                            switch (Ext)
                            {
                                case ".exe":
                                    //Exe file
                                    Response.ContentType = "application/octet-stream";
                                    break;
                                case ".zip":
                                    //Zip file
                                    Response.ContentType = "application/x-zip-compressed";
                                    break;
                                case ".pdf":
                                    //Pdf file
                                    Response.ContentType = "application/pdf";
                                    break;
                                case ".doc":
                                    //MS Word
                                    Response.ContentType = "Application/msword";
                                    break;
                                case ".docx":
                                    //MS Word
                                    Response.ContentType = "Application/msword";
                                    break;
                                case ".dll":
                                    //Dll file
                                    Response.ContentType = "application/x-msdownload";
                                    break;
                                case ".html":
                                    //Html file
                                    Response.ContentType = "text/HTML";
                                    break;
                                case ".txt":
                                    //Txt file
                                    Response.ContentType = "text/plain";
                                    //Response.ContentType = "application/notepad";
                                    break;
                                case ".jpeg":
                                    //Jpg picture
                                    Response.ContentType = "image/JPEG";
                                    break;
                                case ".jpg":
                                    //Jpg picture
                                    Response.ContentType = "image/jpg";
                                    break;
                                case ".bmp":
                                    //bmp picture
                                    Response.ContentType = "image/bmp";
                                    break;
                                default:
                                    Response.ContentType = "application/octet-stream";
                                    break;
                            }
 
			
                            Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
                            Response.TransmitFile(filepath );
                            Response.End();
 
                        }
                    }

Open in new window

sample-code.doc
sample-code-to-open-window-as-mo.doc
0
Comment
Question by:mauneeld
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
mauneeld earned 0 total points
ID: 24855334
(Modal Window) FileUploadNew à opens File DownloadNew.       This was not working.

So what I did was, created a temporary file which will open as a new simple window and that new window will now call FileDownloadNew.

(Modal Window) FileUploadNew à opens FileDownloadTemp (simplewindow) à opens FileDownloadNew. this works fine.

Bhavin
0
 

Expert Comment

by:joy_vinod
ID: 32632991
The solution is not clear.
What is FileUploadNew & DownloadNew. It seems they are some functions in your code, which are not mentioned in the files you have attached.

Could you please explain it in more detail?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to create an MVC5, Razor Widget 2 39
Generate Unique ID in VB.NET 21 105
To open a PDF without getting the prompt "to Save, Open, or Cancel". 6 56
Inspect Elements on iPad 19 57
I had to do a bit of research to find the answer to this question so I thought I'd share my results.  Due to our outdated mainframe systems, we need to downgrade IE9 to IE8 in order to stay compatible.  We also needed to downgrade Java.  In order to…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question