I have a requirement of opening the docx file in the browser. Tried with the code below. But error occurs that the file is corrupt. Is the content type correct, tried with thecontent type application/msword also.
Response.AddHeader("content-disposition", "inline;filename=" + DisplayFileName); Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";//getContentType(filename); Response.WriteFile(fullpath); Response.End(); Response.Flush();
The code works for all other file types when the appropriate content type is given. The problem is only with docx.