4
Answers

Open docx from asp.net


I am trying to open a docx file with the following piece of code.
Response.AddHeader("content-disposition", "inline;filename=DisplayFileName.docx");
Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
Response.WriteFile(fullpath);
Response.Flush();
Response.End();
The problem is that it throws up an error that file is corrupt. Is the above content type correct? Other file types are fine when the appropriate content type is given. The problem is only with docx. Please help. Its urgent...
Answers (4)