473,385 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2884
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.