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. Redirect to Word document???

Redirect to Word document???

Scheduled Pinned Locked Moved ASP.NET
helpquestion
6 Posts 3 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.
  • J Offline
    J Offline
    JimFeng
    wrote on last edited by
    #1

    I need to use response.redirect to a Word document that open with Word (Not IE prowser). When I type the "\\sitename\wwwroot\appfolder\file.doc" in IE address box, the document will be opened with Word. But when I use Response.Redirect("\\sitename\wwwroot\appfolder\file.doc") in my code the address in IE browser becomes to "href="http://siteurl/sitename/wwwroot/appfolder/file.doc" and get "the page can not be fount" error. How can fix the problem?

    M 1 Reply Last reply
    0
    • J JimFeng

      I need to use response.redirect to a Word document that open with Word (Not IE prowser). When I type the "\\sitename\wwwroot\appfolder\file.doc" in IE address box, the document will be opened with Word. But when I use Response.Redirect("\\sitename\wwwroot\appfolder\file.doc") in my code the address in IE browser becomes to "href="http://siteurl/sitename/wwwroot/appfolder/file.doc" and get "the page can not be fount" error. How can fix the problem?

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      If the file.doc is in the same folder as your .aspx page, would it work to simply use the relative path Response.Redirect("file.doc")?

      J 1 Reply Last reply
      0
      • M Mike Ellison

        If the file.doc is in the same folder as your .aspx page, would it work to simply use the relative path Response.Redirect("file.doc")?

        J Offline
        J Offline
        JimFeng
        wrote on last edited by
        #3

        Response.Redirect("file.doc") will open the document in IE browser. I need to open the document in Word.

        M 1 Reply Last reply
        0
        • J JimFeng

          Response.Redirect("file.doc") will open the document in IE browser. I need to open the document in Word.

          M Offline
          M Offline
          Mike Ellison
          wrote on last edited by
          #4

          How it opens on the client is a choice the client gets to make (through their browser settings) - I'm not sure you can limit the client the way you're suggesting (I'd be happy to be proven wrong though)

          J 1 Reply Last reply
          0
          • M Mike Ellison

            How it opens on the client is a choice the client gets to make (through their browser settings) - I'm not sure you can limit the client the way you're suggesting (I'd be happy to be proven wrong though)

            J Offline
            J Offline
            JimFeng
            wrote on last edited by
            #5

            Just like I said above, when I type the "\\sitename\wwwroot\appfolder\file.doc" in IE address box, the document will be opened with Word. Is there any way in a asp.net application that can do the same way?

            G 1 Reply Last reply
            0
            • J JimFeng

              Just like I said above, when I type the "\\sitename\wwwroot\appfolder\file.doc" in IE address box, the document will be opened with Word. Is there any way in a asp.net application that can do the same way?

              G Offline
              G Offline
              gyokusei
              wrote on last edited by
              #6

              if( File.Exists(Server.MapPath("...")) )
              {
              FileStream MyFileStream;
              long FileSize;
              MyFileStream = new FileStream(Server.MapPath("..."), FileMode.Open);
              FileSize = MyFileStream.Length;
              byte[] Buffer = new byte[(int)FileSize];
              MyFileStream.Read(Buffer, 0, (int)FileSize);
              MyFileStream.Close();
              Response.ContentType = "application/msword";
              Response.BinaryWrite(Buffer);
              }
              else
              MessageBox.Show("File not found!");

              This code fragment will ask user download this file. However user can open this file by press open button. Therefore, MSWord will be open. Is there any suggestion?

              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