473,503 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Streaming a word doc to the browser...

Stu
Hi,

I have a Word document that is stored outside of the virtual server and I
need to send it to the browser. I have tried using the code below (which
seemed a little too simplistic!). The browser pops open a dialogue asking to
save a word doc but the doc is empty.
Dim f As File
f.Open("c:\test.doc", FileMode.Open)
'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=test.doc"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition",
"attachment;filename=test.doc")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.Write(f)
f.Delete("c:\test.doc")

How to I route the document to the browser properly?

Thanks in advance,

Stuart
Nov 19 '05 #1
2 9845
Hi Stu,

Use Response.BinaryWrite instead Reponse.Write

Guillermo G.

--------------------------------------------------------------------------------
Guillermo González Arroyave :: MCP ASP.Net C# :: DCE4

"Stu" <s.****@cergis.com> wrote in message news:O2**************@tk2msftngp13.phx.gbl...
Hi,

I have a Word document that is stored outside of the virtual server and I
need to send it to the browser. I have tried using the code below (which
seemed a little too simplistic!). The browser pops open a dialogue asking to
save a word doc but the doc is empty.
Dim f As File
f.Open("c:\test.doc", FileMode.Open)
'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=test.doc"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition",
"attachment;filename=test.doc")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.Write(f)
f.Delete("c:\test.doc")

How to I route the document to the browser properly?

Thanks in advance,

Stuart
Nov 19 '05 #2
Stu
That worked great thanks.
"Guillermo González A." <gugonzar(arroba)epm.net.co> wrote in message
news:Oi**************@TK2MSFTNGP15.phx.gbl...
Hi Stu,

Use Response.BinaryWrite instead Reponse.Write

Guillermo G.
Guillermo González Arroyave :: MCP ASP.Net C# :: DCE4

"Stu" <s.****@cergis.com> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
Hi,

I have a Word document that is stored outside of the virtual server and I
need to send it to the browser. I have tried using the code below (which
seemed a little too simplistic!). The browser pops open a dialogue asking to
save a word doc but the doc is empty.
Dim f As File
f.Open("c:\test.doc", FileMode.Open)
'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=test.doc"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition",
"attachment;filename=test.doc")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.Write(f)
f.Delete("c:\test.doc")

How to I route the document to the browser properly?

Thanks in advance,

Stuart
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1439
by: Eric Sabine | last post by:
I have a web site where the user is able to download a file. I can't use an anchor tag because I don't want the user to see where the filename is coming from. Below is the code in which the user...
1
1698
by: Jonas | last post by:
Hi ! Perhaps this isn't the right group to send to, but... I have exported my report (Crystal Report) to a stream formatted as Word-document. Both the exporting and streaming works just fine...
3
5094
by: Ipsita | last post by:
Hi! I am trying SOAP with DIME attachments in web services. For example say, I have a file resume.pdf stored somewhere on my server. How does the web service send the file to the client, so that...
0
898
by: Rudy Deitrick | last post by:
I'm displaying a Word doc on the client by streaming HTML to the client and setting the ContentType to 'application/msword'. This works fine on our development server (which does not use SSL), but...
1
4341
by: Andrew | last post by:
I'm adding this as it to me a while to figure out all the pieces to be able to do this without using Microsoft.Office.Interop which caused me problems on the web-server. Streaming is the easy...
3
2322
by: A.M-SG | last post by:
Hi, I have a ASP.NET aspx file that needs to pass large images from a network storage to client browser. The requirement is that users cannot have access to the network share. The aspx file...
3
5669
by: Peter | last post by:
Hello! Is it possible to stream a word document to a browser via webservice? Can I use Response.BinaryWrite method or is there some other method in webserices to stream data? The help is very...
2
8420
by: SPG | last post by:
Hi, Two questions for you all.. Firstly, is there a way of streaming video using PHP? At the moment I just have a link to a video file and the whole thing downloads before playing which is a...
5
2128
by: Jim Bancroft | last post by:
Hi everyone, We've have files we'd like to store in a SQL Server blob or text column and make available online for our clients. Instead of linking to a document sitting on a file server, we...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.