Client and Office from asp.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David C

    Client and Office from asp.net

    I have an internal asp.net 2.0 web application where we display the contents
    of various files using Response.Conten tType and Response.WriteF ile()
    settings and it works great for .doc, .xls, etc. files. Now the users want
    to be able to open them in their native programs (Microsoft Word, Excel,
    etc.). I have done this with ActiveX before, but the company has moved to
    Office 2007 and I'm not sure the same process will work for the new docx,
    xlsx, etc. files. Can anyone give me some ideas on the best way to handle
    this? All users have Microsoft Office. Thanks.

    David


  • George Ter-Saakov

    #2
    Re: Client and Office from asp.net

    You should add Content-Disposition to the header.
    Like this Content-Disposition: attachment; filename="file. pdf"

    So in C# code it's Response.AddHea der("Content-Disposition", "attachment ;
    filename=\"file .pdf\"");
    And then do Response.WriteF ile

    Browser will be forced (thanks to "attachment " word) to pop up a window
    offering to save file or open it in application.


    George.


    "David C" <dlchase@lifeti meinc.comwrote in message
    news:efUJQgjpIH A.4620@TK2MSFTN GP06.phx.gbl...
    >I have an internal asp.net 2.0 web application where we display the
    >contents of various files using Response.Conten tType and
    >Response.Write File() settings and it works great for .doc, .xls, etc.
    >files. Now the users want to be able to open them in their native programs
    >(Microsoft Word, Excel, etc.). I have done this with ActiveX before, but
    >the company has moved to Office 2007 and I'm not sure the same process will
    >work for the new docx, xlsx, etc. files. Can anyone give me some ideas on
    >the best way to handle this? All users have Microsoft Office. Thanks.
    >
    David
    >

    Comment

    • David C

      #3
      Re: Client and Office from asp.net

      George,
      Thank you for that info. However, it still does not open in the native
      program (Microsoft Word, Microsoft Excel, etc.). It opens it in the browser
      where it cannot be edited.

      David
      "George Ter-Saakov" <gt-nsp@cardone.com wrote in message
      news:%23Vg$tpjp IHA.4672@TK2MSF TNGP05.phx.gbl. ..
      You should add Content-Disposition to the header.
      Like this Content-Disposition: attachment; filename="file. pdf"
      >
      So in C# code it's Response.AddHea der("Content-Disposition", "attachment ;
      filename=\"file .pdf\"");
      And then do Response.WriteF ile
      >
      Browser will be forced (thanks to "attachment " word) to pop up a window
      offering to save file or open it in application.
      >
      >
      George.
      >
      >
      "David C" <dlchase@lifeti meinc.comwrote in message
      news:efUJQgjpIH A.4620@TK2MSFTN GP06.phx.gbl...
      >>I have an internal asp.net 2.0 web application where we display the
      >>contents of various files using Response.Conten tType and
      >>Response.Writ eFile() settings and it works great for .doc, .xls, etc.
      >>files. Now the users want to be able to open them in their native
      >>programs (Microsoft Word, Excel, etc.). I have done this with ActiveX
      >>before, but the company has moved to Office 2007 and I'm not sure the same
      >>process will work for the new docx, xlsx, etc. files. Can anyone give me
      >>some ideas on the best way to handle this? All users have Microsoft
      >>Office. Thanks.
      >>
      >David
      >>
      >
      >

      Comment

      • George Ter-Saakov

        #4
        Re: Client and Office from asp.net

        Show me the code.....

        PS: There was a bug in IE 5.01 and it ignored the "attachment " .... But I
        hope it's not the case here. Since we already have IE 7.

        George.


        "David C" <dlchase@lifeti meinc.comwrote in message
        news:u4Ka6PvpIH A.4884@TK2MSFTN GP06.phx.gbl...
        George,
        Thank you for that info. However, it still does not open in the native
        program (Microsoft Word, Microsoft Excel, etc.). It opens it in the
        browser where it cannot be edited.
        >
        David
        "George Ter-Saakov" <gt-nsp@cardone.com wrote in message
        news:%23Vg$tpjp IHA.4672@TK2MSF TNGP05.phx.gbl. ..
        >You should add Content-Disposition to the header.
        >Like this Content-Disposition: attachment; filename="file. pdf"
        >>
        >So in C# code it's Response.AddHea der("Content-Disposition", "attachment ;
        >filename=\"fil e.pdf\"");
        >And then do Response.WriteF ile
        >>
        >Browser will be forced (thanks to "attachment " word) to pop up a window
        >offering to save file or open it in application.
        >>
        >>
        >George.
        >>
        >>
        >"David C" <dlchase@lifeti meinc.comwrote in message
        >news:efUJQgjpI HA.4620@TK2MSFT NGP06.phx.gbl.. .
        >>>I have an internal asp.net 2.0 web application where we display the
        >>>contents of various files using Response.Conten tType and
        >>>Response.Wri teFile() settings and it works great for .doc, .xls, etc.
        >>>files. Now the users want to be able to open them in their native
        >>>programs (Microsoft Word, Excel, etc.). I have done this with ActiveX
        >>>before, but the company has moved to Office 2007 and I'm not sure the
        >>>same process will work for the new docx, xlsx, etc. files. Can anyone
        >>>give me some ideas on the best way to handle this? All users have
        >>>Microsoft Office. Thanks.
        >>>
        >>David
        >>>
        >>
        >>
        >
        >

        Comment

        • David C

          #5
          Re: Client and Office from asp.net

          Nevermind. The problem was that I did not need "\" before and after
          filename as I am using VB. When I took them off, it appears to work fine.
          Thanks.

          David
          "George Ter-Saakov" <gt-nsp@cardone.com wrote in message
          news:uTW$GUvpIH A.4292@TK2MSFTN GP04.phx.gbl...
          Show me the code.....
          >
          PS: There was a bug in IE 5.01 and it ignored the "attachment " .... But I
          hope it's not the case here. Since we already have IE 7.
          >
          George.
          >
          >
          "David C" <dlchase@lifeti meinc.comwrote in message
          news:u4Ka6PvpIH A.4884@TK2MSFTN GP06.phx.gbl...
          >George,
          >Thank you for that info. However, it still does not open in the native
          >program (Microsoft Word, Microsoft Excel, etc.). It opens it in the
          >browser where it cannot be edited.
          >>
          >David
          >"George Ter-Saakov" <gt-nsp@cardone.com wrote in message
          >news:%23Vg$tpj pIHA.4672@TK2MS FTNGP05.phx.gbl ...
          >>You should add Content-Disposition to the header.
          >>Like this Content-Disposition: attachment; filename="file. pdf"
          >>>
          >>So in C# code it's Response.AddHea der("Content-Disposition",
          >>"attachment ; filename=\"file .pdf\"");
          >>And then do Response.WriteF ile
          >>>
          >>Browser will be forced (thanks to "attachment " word) to pop up a window
          >>offering to save file or open it in application.
          >>>
          >>>
          >>George.
          >>>
          >>>
          >>"David C" <dlchase@lifeti meinc.comwrote in message
          >>news:efUJQgjp IHA.4620@TK2MSF TNGP06.phx.gbl. ..
          >>>>I have an internal asp.net 2.0 web application where we display the
          >>>>contents of various files using Response.Conten tType and
          >>>>Response.Wr iteFile() settings and it works great for .doc, .xls, etc.
          >>>>files. Now the users want to be able to open them in their native
          >>>>programs (Microsoft Word, Excel, etc.). I have done this with ActiveX
          >>>>before, but the company has moved to Office 2007 and I'm not sure the
          >>>>same process will work for the new docx, xlsx, etc. files. Can anyone
          >>>>give me some ideas on the best way to handle this? All users have
          >>>>Microsoft Office. Thanks.
          >>>>
          >>>David
          >>>>
          >>>
          >>>
          >>
          >>
          >
          >

          Comment

          • David C

            #6
            Re: Client and Office from asp.net

            George,
            I did find a problem. Office 2007 opens a document from a previous version
            of Office with a different name (e.g. it adds [1] to the name). For example,
            if I open test.doc on a machine with office 2007 it opens it as test[1].doc
            in a temporary directory. When it opens a file like test.docx it opens the
            original. Is there any way to handle this? Thanks.

            David
            "George Ter-Saakov" <gt-nsp@cardone.com wrote in message
            news:uTW$GUvpIH A.4292@TK2MSFTN GP04.phx.gbl...
            Show me the code.....
            >
            PS: There was a bug in IE 5.01 and it ignored the "attachment " .... But I
            hope it's not the case here. Since we already have IE 7.
            >
            George.
            >
            >
            "David C" <dlchase@lifeti meinc.comwrote in message
            news:u4Ka6PvpIH A.4884@TK2MSFTN GP06.phx.gbl...
            >George,
            >Thank you for that info. However, it still does not open in the native
            >program (Microsoft Word, Microsoft Excel, etc.). It opens it in the
            >browser where it cannot be edited.
            >>
            >David
            >"George Ter-Saakov" <gt-nsp@cardone.com wrote in message
            >news:%23Vg$tpj pIHA.4672@TK2MS FTNGP05.phx.gbl ...
            >>You should add Content-Disposition to the header.
            >>Like this Content-Disposition: attachment; filename="file. pdf"
            >>>
            >>So in C# code it's Response.AddHea der("Content-Disposition",
            >>"attachment ; filename=\"file .pdf\"");
            >>And then do Response.WriteF ile
            >>>
            >>Browser will be forced (thanks to "attachment " word) to pop up a window
            >>offering to save file or open it in application.
            >>>
            >>>
            >>George.
            >>>
            >>>
            >>"David C" <dlchase@lifeti meinc.comwrote in message
            >>news:efUJQgjp IHA.4620@TK2MSF TNGP06.phx.gbl. ..
            >>>>I have an internal asp.net 2.0 web application where we display the
            >>>>contents of various files using Response.Conten tType and
            >>>>Response.Wr iteFile() settings and it works great for .doc, .xls, etc.
            >>>>files. Now the users want to be able to open them in their native
            >>>>programs (Microsoft Word, Excel, etc.). I have done this with ActiveX
            >>>>before, but the company has moved to Office 2007 and I'm not sure the
            >>>>same process will work for the new docx, xlsx, etc. files. Can anyone
            >>>>give me some ideas on the best way to handle this? All users have
            >>>>Microsoft Office. Thanks.
            >>>>
            >>>David
            >>>>
            >>>
            >>>
            >>
            >>
            >
            >

            Comment

            • George Ter-Saakov

              #7
              Re: Client and Office from asp.net

              Doubt that you can do anything here...
              this is how Open/Save dialog works.....

              If you choose "Save" then you can save it with the name you specified in
              your "Content-Disposition" header.
              If you choose "Open" IE will actually save the file into "TEMP" folder and
              then open application (as if you double clicked on file). But if file with
              that name already exists IE quietly appends [1] (or [2],...) to the name.

              I do not know how to change that behavior andf most likely you can not....


              George.



              "David C" <dlchase@lifeti meinc.comwrote in message
              news:OJSnBcvpIH A.4760@TK2MSFTN GP06.phx.gbl...
              George,
              I did find a problem. Office 2007 opens a document from a previous
              version of Office with a different name (e.g. it adds [1] to the name).
              For example, if I open test.doc on a machine with office 2007 it opens it
              as test[1].doc in a temporary directory. When it opens a file like
              test.docx it opens the original. Is there any way to handle this?
              Thanks.
              >
              David
              "George Ter-Saakov" <gt-nsp@cardone.com wrote in message
              news:uTW$GUvpIH A.4292@TK2MSFTN GP04.phx.gbl...
              >Show me the code.....
              >>
              >PS: There was a bug in IE 5.01 and it ignored the "attachment " .... But I
              >hope it's not the case here. Since we already have IE 7.
              >>
              >George.
              >>
              >>
              >"David C" <dlchase@lifeti meinc.comwrote in message
              >news:u4Ka6PvpI HA.4884@TK2MSFT NGP06.phx.gbl.. .
              >>George,
              >>Thank you for that info. However, it still does not open in the native
              >>program (Microsoft Word, Microsoft Excel, etc.). It opens it in the
              >>browser where it cannot be edited.
              >>>
              >>David
              >>"George Ter-Saakov" <gt-nsp@cardone.com wrote in message
              >>news:%23Vg$tp jpIHA.4672@TK2M SFTNGP05.phx.gb l...
              >>>You should add Content-Disposition to the header.
              >>>Like this Content-Disposition: attachment; filename="file. pdf"
              >>>>
              >>>So in C# code it's Response.AddHea der("Content-Disposition",
              >>>"attachmen t; filename=\"file .pdf\"");
              >>>And then do Response.WriteF ile
              >>>>
              >>>Browser will be forced (thanks to "attachment " word) to pop up a window
              >>>offering to save file or open it in application.
              >>>>
              >>>>
              >>>George.
              >>>>
              >>>>
              >>>"David C" <dlchase@lifeti meinc.comwrote in message
              >>>news:efUJQgj pIHA.4620@TK2MS FTNGP06.phx.gbl ...
              >>>>>I have an internal asp.net 2.0 web application where we display the
              >>>>>contents of various files using Response.Conten tType and
              >>>>>Response.W riteFile() settings and it works great for .doc, .xls, etc.
              >>>>>files. Now the users want to be able to open them in their native
              >>>>>programs (Microsoft Word, Excel, etc.). I have done this with ActiveX
              >>>>>before, but the company has moved to Office 2007 and I'm not sure the
              >>>>>same process will work for the new docx, xlsx, etc. files. Can anyone
              >>>>>give me some ideas on the best way to handle this? All users have
              >>>>>Microsof t Office. Thanks.
              >>>>>
              >>>>David
              >>>>>
              >>>>
              >>>>
              >>>
              >>>
              >>
              >>
              >
              >

              Comment

              • Fernando Rodriguez, MCP

                #8
                Re: Client and Office from asp.net

                I think if you set the content-disposition to inline and the content-type to
                the proper mime type and then stream it down with Response.WriteF ile or
                BinaryWrite it will open automatically on it's application when you click
                the link on a webpage.

                As for using ActiveX, the process would be the same for any type of file
                since you're just embedding the application on the webpage and letting it do
                the rest.


                "David C" <dlchase@lifeti meinc.comwrote in message
                news:efUJQgjpIH A.4620@TK2MSFTN GP06.phx.gbl...
                >I have an internal asp.net 2.0 web application where we display the
                >contents of various files using Response.Conten tType and
                >Response.Write File() settings and it works great for .doc, .xls, etc.
                >files. Now the users want to be able to open them in their native programs
                >(Microsoft Word, Excel, etc.). I have done this with ActiveX before, but
                >the company has moved to Office 2007 and I'm not sure the same process will
                >work for the new docx, xlsx, etc. files. Can anyone give me some ideas on
                >the best way to handle this? All users have Microsoft Office. Thanks.
                >
                David
                >

                Comment

                Working...