Question

I use this code to export/open files (pdf/xls/doc).

Response.Clear();
Response.Buffer = true;

Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Charset = "UTF-8";
Response.ContentType = mimeType;

Response.AppendHeader("content-disposition", "inline; filename=" + fileName + "." + extension);

Response.BinaryWrite(bytes);
Response.End();

When I open a doc file with Word and click export to xls or pdf, nothing happens until I close Word. After I close Word I am already able to open xls and pdf too.

This problem exists when I open xls with Excel.

What is the reason?

Was it helpful?

Solution 2

Depending on the word version you use, I would say that the problem comes from the inline content-disposition

In recent versions of Word ( seen in Word 2010 ), it tries to open the document in WEBDAV mode when inline, which might cause issues (locks, missing cookies or credential when trying to export/print the document)

You may look at your network traffic to see if this WEBDAV behavior is involved, and see if content-disposition attachment solves the problem.

Hope this will help

OTHER TIPS

The reason is because Word, and other Word-like programs lock the open files to avoid double open again. So the locked file can not be opened again from your application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top