I am trying to get a Silverlight 4.0 application to run a file extension associated with it when a user clicks something to translate it to their web URL, but I have a difference in whether I use HtmlPage.Window.Navigate or HyperlinkButton.
My web url is a RESTful url for my resource, for example. "HTTP: //.../objects/object-1/package". The URL is actually an ASP.NET MVC 2 controller that returns email content using a custom extension. That is, the headers of the HTTP response look like this:
HTTP/1.1 200 OK Server: ASP.NET Development Server/10.0.0.0 Date: Wed, 13 Apr 2011 17:22:19 GMT X-AspNet-Version: 4.0.30319 Content-Disposition: attachment; filename=object-1.pkg Transfer-Encoding: chunked Cache-Control: private Content-Type: application/zip Connection: Close
When I use a hyperlink, Internet Explorer prompts me to open, save, or cancel. When I select Open, it opens the application that I linked to * .pkg:
<HyperlinkButton TargetName="_blank" NavigateUri="http://localhost:8023/objects/object-1/package">Launch!</HyperlinkButton>
However, if I instead use a command that ultimately uses HtmlPage.Window.Navigate, IE just opens a window and then quickly closes:
string url = string.Format("{0}/objects/object-{1}/package", _webBaseUrl, objectId.Value); Uri uri = new Uri(url); HtmlPage.Window.Navigate(uri, "_blank");
I checked the use of Fiddler2, which in both cases the HTTP requests and the HTTP responses look the same. This seems to be either an Internet Explorer nuance or Silverlight, which I'm not sure I can overcome, but I hope the Stackoverflow community can confirm or deny this problem.