Skip to content

Open docx from asp.net

Sandhya Chandrasekharan

Asked Oct 13, 2010, 5:21 AM EDT4 answers
Share
LinkedInX
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...

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.