0

I have a user who, when they download an excel file hosted on our intranet, receives an error message telling them that the file doesn't exist. This occurs for her in IE.

I've verified that the file does in fact exist, and that it can be accessed by other users with the same permissions in the same geographic location. This is not an interop issue - the file is just being hosted. I was able to reproduce the issue once from my machine in IE 9 by opening the file at the open/save prompt, after which Excel asked me for authentication credentials 3 times, gave me the same error, then opened the file anyway. I have since been unable to reproduce it. Her computer will "open the file anyway."

I am stumped. Does anyone have any ideas?

Error message: Microsoft Office Excel cannot access the file . There are several possible reasons:

  • The file name or path does not exist.
  • The file is being used by another program.
  • The workbook you are trying to save has the same name as a currently open workbook.

Edit

The user is using IE 7.

Code serving the file:

<asp:LinkButton ID="lbtnEstimatingWorkbook" runat="server" CssClass="Brightness"
    Tooltip="Estimate Calculation Workbook" ToolTip="Open estimating workbook in Excel"
    OnClientClick="DisplayEstimateWorkbook()"></asp:LinkButton>

function DisplayEstimateWorkbook() {
    var url = "Estimating Workbook.xlsm";
    var win = window.open(url, '_blank');
    win.focus();
}
Travis
  • 1,044
  • 1
  • 17
  • 36
  • What part of this process involves ASP.NET? Could you give some code snippets showing how you send the Excel file? – Garrison Neely Jul 17 '13 at 21:48
  • 1
    Did you investigate the three possible reasons that you posted? But this doesn't seem to be a programming question. – Andy G Jul 17 '13 at 22:12
  • Yeah, I kind of failed to really define the problem. The download uses an ASP.net linkbutton which calls a Javascript function to open the file in a new window, prompting the download dialog. I've updated the question to include the code, and added the Javascript keyword. I have indeed investigated the 3 posted possibilities. The file does exist, as mentioned in the original question. It is a fresh download each time, so it cannot be used by another program, and the user did not have any Excel document open while I watched the error happen. – Travis Jul 18 '13 at 20:38

1 Answers1

0

Turns out something along our production path (probably a generic IIS setting), but outside of the application, was adding the "Pragma: no-cache" header. This was preventing IE8 (or earlier) from downloading anything because of the terrible way IE handled downloads.

Adding the following to the Init method of the page fixed the problem and allowed downloads (only works with IIS 7+):

Response.Headers.Remove("Pragma")
Response.AddHeader("Pragma", "cache")
Response.Cache.SetCacheability(HttpCacheability.Private)
Response.Cache.SetMaxAge(New TimeSpan(0, 15, 0))

This question has more information.

Community
  • 1
  • 1
Travis
  • 1,044
  • 1
  • 17
  • 36