Unable to download files from application in Mozilla firefox

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.

if (!IsPostBack)
                if (Request.QueryString.ToString() == "instructions")
                    pnlInstructions.Visible = true;
                    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.Buffer = true;
                            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";
                                case ".zip":
                                    //Zip file
                                    Response.ContentType = "application/x-zip-compressed";
                                case ".pdf":
                                    //Pdf file
                                    Response.ContentType = "application/pdf";
                                case ".doc":
                                    //MS Word
                                    Response.ContentType = "Application/msword";
                                case ".docx":
                                    //MS Word
                                    Response.ContentType = "Application/msword";
                                case ".dll":
                                    //Dll file
                                    Response.ContentType = "application/x-msdownload";
                                case ".html":
                                    //Html file
                                    Response.ContentType = "text/HTML";
                                case ".txt":
                                    //Txt file
                                    Response.ContentType = "text/plain";
                                    //Response.ContentType = "application/notepad";
                                case ".jpeg":
                                    //Jpg picture
                                    Response.ContentType = "image/JPEG";
                                case ".jpg":
                                    //Jpg picture
                                    Response.ContentType = "image/jpg";
                                case ".bmp":
                                    //bmp picture
                                    Response.ContentType = "image/bmp";
                                    Response.ContentType = "application/octet-stream";
                            Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
                            Response.TransmitFile(filepath );

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mauneeldAuthor Commented:
(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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.