Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with response.write and offcie documents

Problem with response.write and offcie documents

Scheduled Pinned Locked Moved ASP.NET
helpsysadminwindows-admin
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ritesh1234
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • R Ritesh1234

      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

      A Offline
      A Offline
      Abhishek Joshi
      wrote on last edited by
      #2

      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>

      R 1 Reply Last reply
      0
      • A Abhishek Joshi

        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>

        R Offline
        R Offline
        Ritesh1234
        wrote on last edited by
        #3

        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

        R 1 Reply Last reply
        0
        • R Ritesh1234

          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

          R Offline
          R Offline
          Ritesh1234
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups