Click here to Skip to main content
13,044,282 members (105,740 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i want to develop asp application that view the any office document
and i used
to display the document

and this is the code
if (URL.Contains(".doc"))//URL is document path
                  Response.ContentType = "application/msword";

but when i run , display a downloaded dialog and didn't view any thing

the MIMI list

any idea to display document in browser , i need it necessary

Posted 27-Feb-13 2:42am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You cannot display doc file in browser without saving it, if you want then you have to write plugin with respect to each browser and that is a very length code of work. A PDF can be opened in a browser, if you can convert doc to pdf that could be an easy solution.
Good luck
Darsh_Basha 27-Feb-13 10:06am
@Anuja Pawar Indore

thx for replay , but your idea is not good

i want to use
Collapse | Copy Code
Response.ContentType = "application/msword";
and why convert the document to pdf

Anuja Pawar Indore 27-Feb-13 10:11am
Its not converting to PDF, but pdf can be opened in browser.
have a look at this
aspnet_regiis -i 27-Feb-13 12:28pm
I agree with Anuja..Browsers do not natively support office documents. If you think the answer is wrong then show us a website which opens them in browser. And to add to the answer, most browsers do not support PDF too..You need to read doc contents and display them in HTML +5
Darsh_Basha 28-Feb-13 3:43am

@Anuja Pawar Indore
@Anuja Pawar Indore
using Microsoft.Office.Interop.Word;// Microsoft.Office.Interop.Word reference

private void readFileContent(string path )


ApplicationClass wordApp = new ApplicationClass();

object file = path;

object nullobj = System.Reflection.Missing.Value;
object format = true;

Microsoft.Office.Interop.Word.Document doc =wordApp.Documents.Open(

ref file,
ref nullobj,
ref nullobj,

ref nullobj,
ref nullobj,
ref nullobj,

ref nullobj,
ref nullobj,
ref nullobj,

ref format,
ref nullobj,
ref nullobj,
ref nullobj,
ref nullobj,
ref nullobj,
ref nullobj);



string sFileText = doc.Content.Text;
string style = doc.

doc.Close(ref nullobj, ref nullobj, ref nullobj);

wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);



this function open the content of the word file in web,but without word style
Anuja Pawar Indore 28-Feb-13 8:50am
The above code opens and fill a Word file from File System, if this is what you need, then good
Darsh_Basha 28-Feb-13 9:42am
but this not i want to do

Anuja Pawar Indore 28-Feb-13 9:46am
You wont find any site which opens doc file in browser. Think something else, i m telling you from my past 13yrs of experience :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100