468,268 Members | 1,714 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

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 2720
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jerry J | last post: by
6 posts views Thread by Martin Knopp | last post: by
2 posts views Thread by Carter | last post: by
2 posts views Thread by David Union | last post: by
8 posts views Thread by Scott C. Reynolds | last post: by
1 post views Thread by Ryan Pedersen | last post: by
3 posts views Thread by Buddy Ackerman | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.