views:

2438

answers:

3

Hi All, I'm having a problem with IE only in my Silverlight application. Since Silverlight 2 doesn't include a mechanism for file downloads I was left to my own devices to come up with a solution. The way I did it was as follows:

HtmlPage.Window.Navigate(new Uri(sb.ToString(), UriKind.Relative));

My StringBuilder contains the relative url with query string to a *.ashx handler on the server that reads the query string, gets some data from the database, and returns an Excel file.

When I do this I get a blocked file download bar in IE only. I understand that this is a new security "feature" in IE and that it is being blocked because it believes that the download wasn't triggered by the user interaction with the web page. The users can choose to allow the download and that setting seems to be remembered for the rest of the session. However next time they open the page it happens again. Even if the site is in the Trusted zone and even if the popup blocker is configured to allow popups for the site.

Does anyone know how to make IE know that the user did in fact request this file?

A: 

Hi,

In my case only happended the first time (using IE 7), maybe that happens on your local dev instance?

I think there's not much you can do, even MSDN pages tells you that "a message will appear on top of...", things that could mitigate this:

  • Warn the user that the message will be shown, then once he clicks the app is reset (Store the current app state in the isolated storage, when you receive the reset reload the app with the settings).

  • Open a popup, and in the popup include and standard HTML button to download.

HTH Braulio

Braulio
A: 

Check the headers?

jminkler
+1  A: 

I had exactly the same problem. The solution for me was to not use HtmlPage.Window.Navigate, but to instead use a HyperlinkButton and dynamically set the NavigateUri property.

Saving and restoring the app state as suggested above didn't work. Well, it did, but it was impossible to determine when it needed to be done and when it didn't. So, ultimately, it didn't really work.

See this discussion on codeplex....

http://slideshow2.codeplex.com/Thread/View.aspx?ThreadId=60242