ah, sorry.. I misunderstood.
In that case I think you need to convert the doc file to html and then load html content directly on browser. Here is sample code to convert doc to html and then load the html in browser:
private void OpenMSWordFileByBrowser()
{
string htmlFilePath = "E:\\test.html";
Convert("E:\\test.docx",htmlFilePath, WdSaveFormat.wdFormatHTML);
Response.ClearContent();
Response.ClearHeaders();
Response.WriteFile(htmlFilePath);
Response.Flush();
Response.Close();
}
private static void Convert(string docFilePath,string htmlFilePath, WdSaveFormat format)
{
DirectoryInfo dirInfo = new DirectoryInfo(docFilePath);
FileInfo wordFile = new FileInfo(docFilePath);
object oMissing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
try
{
word.Visible = false;
word.ScreenUpdating = false;
Object filename = (Object)wordFile.FullName;
Document doc = word.Documents.Open(ref filename, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);
try
{
doc.Activate();
object outputFileName = htmlFilePath;
object fileFormat = format;
doc.SaveAs(ref outputFileName,
ref fileFormat, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);
}
finally
{
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
((_Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing);
doc = null;
}
}
finally
{
((_Application)word).Quit(ref oMissing, ref oMissing, ref oMissing);
word = null;
}
}
Instead of physical file location you can use relative path if the doc file exists in your application folder and use server.mappath.