473,471 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Use Response.WriteFile to display .doc file

I has a question:
I can use Response.WriteFile to display images such as .jpg.
But I can not us it to display words doc file in EI by calling
Response.WriteFile("testdoc/DownloadLarge.doc").
It only shows unreadable chars.

How to use it to show the doc file on webrowser?

Thanks

David
Nov 19 '05 #1
4 2889
Try setting the content type and making sure nothing else gets sent along
the way....

Response.ClearContent()
Response.ClearHeaders();
Response.ContentType = "application/msword"
Response.WriteFile(ExportPath)
Response.Flush()
Response.Close()

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
I has a question:
I can use Response.WriteFile to display images such as .jpg.
But I can not us it to display words doc file in EI by calling
Response.WriteFile("testdoc/DownloadLarge.doc").
It only shows unreadable chars.

How to use it to show the doc file on webrowser?

Thanks

David

Nov 19 '05 #2
Thank you very much, Karl.
It works!
Could you give some hint about my next question:
(1) Whether the ContentType msword is predefined in browser in the code:
Response.ContentType = "application/msword"
(2) If I have my own file processing application, say, fileapp, which can be
running in client side. Can I use the following code?
Response.ContentType = "application/fileapp"

Thanks

David

"Karl Seguin" wrote:
Try setting the content type and making sure nothing else gets sent along
the way....

Response.ClearContent()
Response.ClearHeaders();
Response.ContentType = "application/msword"
Response.WriteFile(ExportPath)
Response.Flush()
Response.Close()

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
I has a question:
I can use Response.WriteFile to display images such as .jpg.
But I can not us it to display words doc file in EI by calling
Response.WriteFile("testdoc/DownloadLarge.doc").
It only shows unreadable chars.

How to use it to show the doc file on webrowser?

Thanks

David


Nov 19 '05 #3
Take a look at:
http://ppewww.ph.gla.ac.uk/~flavell/...tent-type.html

when you set the content-type you are just sending some helpful information
to the browser for it to know how to open the file. The browser (a) might
not know what to do with the specified content type or (b) might override
your suggestion (ie, just because you sent application/msword, the browser
coudl decide to open the file up in notepad)...

To get your own content type to work in a browser, users must configure
their browsers to recognize the content type and associate with the
appropriate action (ie, open your application). There are certainly ways
to do this, but I don't have the slightest idea how :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Thank you very much, Karl.
It works!
Could you give some hint about my next question:
(1) Whether the ContentType msword is predefined in browser in the code:
Response.ContentType = "application/msword"
(2) If I have my own file processing application, say, fileapp, which can
be
running in client side. Can I use the following code?
Response.ContentType = "application/fileapp"

Thanks

David

"Karl Seguin" wrote:
Try setting the content type and making sure nothing else gets sent along
the way....

Response.ClearContent()
Response.ClearHeaders();
Response.ContentType = "application/msword"
Response.WriteFile(ExportPath)
Response.Flush()
Response.Close()

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
>I has a question:
> I can use Response.WriteFile to display images such as .jpg.
> But I can not us it to display words doc file in EI by calling
> Response.WriteFile("testdoc/DownloadLarge.doc").
> It only shows unreadable chars.
>
> How to use it to show the doc file on webrowser?
>
> Thanks
>
> David


Nov 19 '05 #4
Thanks.
I will try to figure it out.
David

"Karl Seguin" wrote:
Take a look at:
http://ppewww.ph.gla.ac.uk/~flavell/...tent-type.html

when you set the content-type you are just sending some helpful information
to the browser for it to know how to open the file. The browser (a) might
not know what to do with the specified content type or (b) might override
your suggestion (ie, just because you sent application/msword, the browser
coudl decide to open the file up in notepad)...

To get your own content type to work in a browser, users must configure
their browsers to recognize the content type and associate with the
appropriate action (ie, open your application). There are certainly ways
to do this, but I don't have the slightest idea how :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Thank you very much, Karl.
It works!
Could you give some hint about my next question:
(1) Whether the ContentType msword is predefined in browser in the code:
Response.ContentType = "application/msword"
(2) If I have my own file processing application, say, fileapp, which can
be
running in client side. Can I use the following code?
Response.ContentType = "application/fileapp"

Thanks

David

"Karl Seguin" wrote:
Try setting the content type and making sure nothing else gets sent along
the way....

Response.ClearContent()
Response.ClearHeaders();
Response.ContentType = "application/msword"
Response.WriteFile(ExportPath)
Response.Flush()
Response.Close()

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
>I has a question:
> I can use Response.WriteFile to display images such as .jpg.
> But I can not us it to display words doc file in EI by calling
> Response.WriteFile("testdoc/DownloadLarge.doc").
> It only shows unreadable chars.
>
> How to use it to show the doc file on webrowser?
>
> Thanks
>
> David


Nov 19 '05 #5

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

Similar topics

2
by: Jerry J | last post by:
I am using Response.WriteFile to send file streams back to web clients. My question is this: Can I use Response.WriteFile(SomeFilePath) for any size file? Will it handle chunking the data...
6
by: Martin Knopp | last post by:
I have a site running under SSL. Works well so far but there is one ASPX page which returns a dynamically created PDF file using Response.WriteFile. When the browser requests this ASPX page via...
2
by: Carter | last post by:
i have a treeview on a webform (.aspx). when the user selects an appropriate node on the tvw. and clicks on a link button, i'm downloading a corresponding file to the client (from the server). so far...
0
by: ProJee | last post by:
Hi, Response.WriteFile (or Response.OutputStream.Write) finishes immediately, not after the file is completely downloaded. It finishes before (!) the user clicks the "Save" or "Open" browser...
2
by: David Union | last post by:
Hi. I'm posting this here because I don't know exactly what the best group is. This is for an aspx page with Visual Basic as the code-behind page. I am doing very simple code... in the middle...
8
by: Scott C. Reynolds | last post by:
I want to serve a PDF right to a web page (cannot link browser directly to PDF file). Stumbled across Response.WriteFile this morning. On my machine (XP Pro) this worked fine: private void...
1
by: Ryan Pedersen | last post by:
I have been trying to figure out how to transmit a file back to a user using the response.transmitfile or response.writefile method and just not having much success. I have a dell server running...
3
by: Buddy Ackerman | last post by:
I'm trying to write files directly to the client so that it forces the client to open the Save As dialog box rather than display the file. On some occasions the files are very large (100MB+). On...
3
by: MJP | last post by:
I have a button which kicks off the generation of a report after which the file will be downloaded. The report generation can take a long time, so client side onclick event of the button also...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.