Hi,
in this article I'll describe an easy way to display a word document's content in web page.
First, you'll need Microsoft.Office.Interop.Word.dll
What is Microsoft.Office.Interop.Word.dll ?
Microsoft.Office.Interop.Word.dll is a component from the software Microsoft Office (versions XP, 2003 and 2007) by Microsoft Corporation.
For example: If you've installation of Microsoft Office 2007 and Visual Studio 9.0, Microsoft.Office.Interop.Word.dll could be found in this directory:
C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\
How to show word document's content in your web pages ?
In your asp.net project, add reference to Microsoft.Office.Interop.Word.dll:
in the project we've a doc file:
the document contains some text:

in the aspx page we have this code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DispalyWordDocApp._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Literal ID="_dispalyLiteral" runat="server"></asp:Literal>
</div>
</form>
</body>
</html>
Just a Literal control which will contain the text of the document.
in code-behind class:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using Microsoft.Office.Interop.Word;
namespace DispalyWordDocApp
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
object fileName = Server.MapPath("~/test.doc");
object falseValue = false;
object trueValue = true;
object missing = Type.Missing;
Microsoft.Office.Interop.Word.Document doc = word.Documents.Open(ref fileName,
ref missing, ref trueValue, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
// we replace '\v' with '<br />' for better vizualization in web
_dispalyLiteral.Text = doc.Content.Text.Replace("\v", "<br />");
}
catch (Exception ex)
{
_dispalyLiteral.Text = "Exception: " + ex.ToString();
}
}
}
}
Code Explanation
Microsoft.Office.Interop.Word.Application class represents the Microsoft Office Word application.
Microsoft.Office.Interop.Word.Document class represents a document (in our example doc represents the file 'test.doc').
Now, compile and run, the result:
That's all! Now we can view the doc in the browser!
An Important Note
Installing Office on a server is not recommended by Microsoft, so I'm not sure how this could be used in practice, but there's only one way to understand that :)
I hope this article will be useful for someone! Good Luck!