Problem with response.write and offcie documents
-
Hi, My web application is hosted on windows2003 server (IIS 6.0).I am facing one strange problem on client machine, i use response.redirect("url for Office document like .doc,.xls") to open the any attacment with the records, in some of the machine the attachement open properly but in some it's not(it seems like client gets back the response and page appear for fraction on time and gets dissapear.) even when i run the application on server itslef i notice that attachment getting open when i use http://localhost in my url but problem occurs when i use IP address or machine name. Is it something related to IE setting or some setting of IIS. but the things work perfectly on any machine if attachment is pdf file. Any help will be appreciated. Regards, Ritesh
-
Hi, My web application is hosted on windows2003 server (IIS 6.0).I am facing one strange problem on client machine, i use response.redirect("url for Office document like .doc,.xls") to open the any attacment with the records, in some of the machine the attachement open properly but in some it's not(it seems like client gets back the response and page appear for fraction on time and gets dissapear.) even when i run the application on server itslef i notice that attachment getting open when i use http://localhost in my url but problem occurs when i use IP address or machine name. Is it something related to IE setting or some setting of IIS. but the things work perfectly on any machine if attachment is pdf file. Any help will be appreciated. Regards, Ritesh
Do following steps. 1. Include "Microsoft Office 11.0 Object Library" on your project and get file content of your file using following steps Word.ApplicationClass wordApp = null; Word.Document doc doc = wordApp.Documents.Open(ref file,ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing); //Save the contents of File in database as string str = doc.Content.Text; //Save str to database 2. Open a temp page as follows. Response.Write(""); Response.Write("window.open('temp.aspx');"); Response.Write("</"+"script>"); 3. On this temp.aspx page load do following steps //Retrieve File contents eighter form database wich we have saved in step1 byte [] FileContent = (byte[])row["FileContent"]; Response.Clear(); Response.AddHeader("Content-disposition", "inline;filename="+FileName); Response.ContentType = "application/msword"; Response.BinaryWrite(FileContent); Response.End(); //If this not works then do following HttpContext.Current.Response.BinaryWrite(FileContent); Response.End(); :-> <div class="ForumSig"> #Abhi#</div></x-turndown>
-
Do following steps. 1. Include "Microsoft Office 11.0 Object Library" on your project and get file content of your file using following steps Word.ApplicationClass wordApp = null; Word.Document doc doc = wordApp.Documents.Open(ref file,ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing); //Save the contents of File in database as string str = doc.Content.Text; //Save str to database 2. Open a temp page as follows. Response.Write(""); Response.Write("window.open('temp.aspx');"); Response.Write("</"+"script>"); 3. On this temp.aspx page load do following steps //Retrieve File contents eighter form database wich we have saved in step1 byte [] FileContent = (byte[])row["FileContent"]; Response.Clear(); Response.AddHeader("Content-disposition", "inline;filename="+FileName); Response.ContentType = "application/msword"; Response.BinaryWrite(FileContent); Response.End(); //If this not works then do following HttpContext.Current.Response.BinaryWrite(FileContent); Response.End(); :-> <div class="ForumSig"> #Abhi#</div></x-turndown>
Hi Abhishek, thanks you very much for you reply.currently i am doing same steps,i.e opening temp. page and doing response.redirect to target file,It was my mistake that i forgot to mention that my application is sort of document management system and it stores file with any extension on FTP server.As sugested by you in Step 3 is mainly deal with msword documents,but i am also facing same problem with autocad (.dwg) files. and in my temp page i am also doing further proecessing of file like converting it into pdf format and applying watermark onfly etc, so i guess converting files into binary format further slowdown the whole process (as size of files are in 10+MB). I am not sure but i guess it has something to do with mime setting as when i added *.* in the mime type list of my iis server it's work file (but only if i use localhost in my url). If you can have any suggestion i would be very helpfull.... thanks, Ritesh
-
Hi Abhishek, thanks you very much for you reply.currently i am doing same steps,i.e opening temp. page and doing response.redirect to target file,It was my mistake that i forgot to mention that my application is sort of document management system and it stores file with any extension on FTP server.As sugested by you in Step 3 is mainly deal with msword documents,but i am also facing same problem with autocad (.dwg) files. and in my temp page i am also doing further proecessing of file like converting it into pdf format and applying watermark onfly etc, so i guess converting files into binary format further slowdown the whole process (as size of files are in 10+MB). I am not sure but i guess it has something to do with mime setting as when i added *.* in the mime type list of my iis server it's work file (but only if i use localhost in my url). If you can have any suggestion i would be very helpfull.... thanks, Ritesh
Hi, After some R&D i think i figured out the solution...........it all has do to with IE 6.0 's trusted site's security setting.I just set "Automatic Promting for file download" setting to enable and it works fine. Regards, Ritesh