Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET HTML
Hi
 
i want to develop asp application that view the any office document
and i used
 Response.ContentType
to display the document
 
and this is the code
if (URL.Contains(".doc"))//URL is document path
                  Response.ContentType = "application/msword";
        Response.WriteFile(URL);
        Response.Flush();
        Response.Close();
 
but when i run , display a downloaded dialog and didn't view any thing
 
the MIMI list

http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/05/08/office-2007-open-xml-mime-types.aspx
[^]
 
any idea to display document in browser , i need it necessary
 
Thx
Posted 27-Feb-13 2:42am

1 solution

Rate this: bad
good
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
  Permalink  
Comments
Darsh_Basha at 27-Feb-13 10:06am
   
Hi
@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

thx
Anuja Pawar Indore at 27-Feb-13 10:11am
   
Its not converting to PDF, but pdf can be opened in browser.
have a look at this
http://stackoverflow.com/questions/2519026/how-do-you-stream-an-excel-2007-or-word-2007-file-using-asp-net-and-c-sharp
aspnet_regiis -i at 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 at 28-Feb-13 3:43am
   
Hi
 
@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);
 

 
doc.ActiveWindow.Selection.WholeStory();
 
doc.ActiveWindow.Selection.Copy();
 
string sFileText = doc.Content.Text;
string style = doc.

doc.Close(ref nullobj, ref nullobj, ref nullobj);
 
wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
 
Response.Write(word);
 
}
 
this function open the content of the word file in web,but without word style
thx
Anuja Pawar Indore at 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 at 28-Feb-13 9:42am
   
sorry
but this not i want to do
 
Anuja Pawar Indore at 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
0 Sergey Alexandrovich Kryukov 410
1 Maciej Los 258
2 CHill60 222
3 OriginalGriff 210
4 Sinisa Hajnal 125


Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2014
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