Open docx from asp.net

Oct 13 2010 9:21 AM

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)