Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

I want asp code to open doc file in browser, as it is formated in Microsoft office,
I dont want to download or save that file on local pc, i want to show doc/ppt file in user browser.
Posted
Updated 20-Sep-13 2:17am
v2
Comments
Thanks7872 20-Sep-13 8:22am    
And? Where is the code you have tried till now?
Sumit Memane 20-Sep-13 8:23am    
Here is code.
string strPath = @"C:\sample.docx";

System.IO.FileInfo file = new System.IO.FileInfo(strPath);

if (file.Exists == true)
{
Response.Clear();
Response.AddHeader("content-disposition", "inline; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/doc";
Response.WriteFile(file.FullName);
Response.End();
Response.Flush();
}

1 solution

Similar question with a few answers:

http://stackoverflow.com/questions/5001497/word-document-viewer-browser-plugin[^]

Check out the first answer. I don't think you can possibly do anything on the server side.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900