Link to home
Start Free TrialLog in
Avatar of slm_tycoon
slm_tycoon

asked on

File Download Hangs

A very strange problem.  The following code works everywhere except on client pc’s.

public void excelConvert(DataSet ds, HttpResponse response, string reportName)
{
      System.IO.StringWriter  stringWrite = new System.IO.StringWriter();
      System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);

      DataGrid dg = new DataGrid();
      dg.DataSource = ds.Tables[0];
      dg.DataBind();
      dg.HeaderStyle.Font.Bold = true;
      dg.RenderControl(htmlWrite);

      response.Clear();
      response.Charset = "";
      response.ContentType = "application/vnd.ms-excel";
      response.AddHeader("Content-Disposition", "attachment;filename="+reportName+".xls");
      response.Write(stringWrite);
      response.Flush();
      response.End();
}

In our development environment (and most everywhere else) this code will cause  the Open/Save/Cancel dialog to display. When you  select Open, Excel is launched and the spreadsheet displayed.  Selecting Save works as you would expect.  In the production environment, Open/Save/Cancel dialog displays,  you select Open and it hangs on  File Download. And will stay there forever.  Selecting save acts the same, hangs on File Download.  The odd thing is that if you look in the Internet Temp Files directory on the failing client you will see that the .xls file requested is there, but Excel is never launched.  I’ve been on the phone with Microsoft Support for 2 days and nothing. They were able to run my code fragment there with no problems.  I have this code running on a number of tester systems and it runs fine.  Simple question (hard answer) why does this rather straight forward piece of code not work on the clients PC?  

One other hints: If I boot the failing client in Safe Mode it works fine.  

It seems like some permissions/policy issue but I can’t  figure it out.

Any ideas would be appreciated.
Avatar of Sammy
Sammy
Flag of Canada image

have you tried different browsers? try using firefox on a failing client PC and see if you get the expected results or another failure
Avatar of slm_tycoon
slm_tycoon

ASKER

sammy1971

my client only uses IE
another thing that would cause this is having an active antivirus attempting to scan the .xls file as its being opened or downloaded.
sammy1971

nope, turned off virus scan

tried all the usual stuff.  you see, the file is in the temp directory and i can open it and it looks fine.

what would stop the launch of the target application?

nothing on the group policies, either N/A or none

one other thing,  
response.AddHeader("Content-Disposition", "inline;filename="+reportName+".xls");
works

that is really strange
you got that right!

i've had IIS, ASP.NET, and IE guys/gals from MS on the phone for 2 days and all they can come up with is it a 3rd party application/service that is causeing the problem.  THANKS. now what?

i have to agree with one thing, that it feels like some kind of "permissions" thing. i just can't identify what it is.
ASKER CERTIFIED SOLUTION
Avatar of Sammy
Sammy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sammy1971

tried that.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ramuncikas

nope



Well, I think it is a situation where problem comes NOT from your code, but from client workstation. I guess you know that when you install software remove it then install another one then remove again and so on then computer becomes king of buggy. Another factor is viruses, ad-ware, spyware, amount of them and the way they were removed. As a result of this is "dirty" windows registry whitch infact very often has impact like this in situations like this. At these situations I don't bother myself with questions how to fix this or that but I just do a clean reinstall of my computer. Yes, it's time consuming but I think it's worth it.
I don't know for sure but I think that your page hangs on 10% of computers you tested at most. So I suppose these are computers that fall under the problems whitch I described here (and not only these).
My suggestions would be:
#1. Try to google with keywords like "IE hang download open save"
#2. In windows explorer go to Menu Tools/Folder options, open File Types tab, find a XLS extention, select it and hit the Advanced button. There is a checkbox "Confirm open after download". I don't know what impact it has but worth to play with it.
#3. Try using utility like TuneUp Utilities. I've used it several times with luck. Very helpful to clean registry from missing/invalid references in registry. Of course if you are not the owner of a "fault" computer then you should get owner's permition to do that.

Again I'm 90% sure that it's not about your code
Thanks to all for the ideas but nothing helped.
Solved the problem!

Seems that a single signon product was "pushed" to some client PCs and, for some reason, it stopped the launch of the streamed file.  When it was uninstalled, all was right again.  Still need to look into why that happens but at least now I know what was causing the problem.

You guys made the effort.
Hi Slm_tycoon,

not sure if you're still following this thread ...

We are experiencing exactly the same problem with Single Sign On. Did you find a solution?