Silverlight的HtmlPage.Window.Navigate和HyperlinkBut​​ton之间的区别?

| 我试图让我的Silverlight 4.0应用程序在用户单击某些内容以将其链接到其Web URL时启动关联的程序文件的文件扩展名,但是无论我使用HtmlPage.Window.Navigate还是Windows,我都有不同的经验HyperlinkBut​​ton。 我的网页网址是我资源的RESTful网址,例如\“ http://.../objects/object-1/package \”。该URL实际上是一个ASP.NET MVC 2控制器,该控制器返回具有自定义扩展名的zip内容。也就是说,HTTP响应标头如下所示:
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
当我使用超链接按钮时,Internet Explorer会提示我打开,保存或取消。当我选择“打开”时,它将打开与* .pkg关联的应用程序:
<HyperlinkButton TargetName=\"_blank\" NavigateUri=\"http://localhost:8023/objects/object-1/package\">Launch!</HyperlinkButton>
但是,如果我改用最终使用HtmlPage.Window.Navigate的命令,则IE只是打开一个窗口,然后快速关闭:
string url = string.Format(\"{0}/objects/object-{1}/package\", _webBaseUrl, objectId.Value);
Uri uri = new Uri(url);
HtmlPage.Window.Navigate(uri, \"_blank\");
我已经使用Fiddler2进行了验证,在两种情况下,HTTP请求和HTTP响应看起来都是相同的。这似乎是Internet Explorer或Silverlight的细微差别,我不确定是否可以克服,但是我希望Stackoverflow社区可以确认或拒绝此问题。     
已邀请:
这里有一篇简短的文章阐明了这个问题-我发现
HtmlPage.Window.Navigate
在IE之外对我都不起作用。 但是回到原始问题,使用dotPeek可以看到以下差异: 跟踪HyperlinkBut​​ton OnClick,它将调用委派给agcore:(XcpImports.cs)
[DllImport(\"agcore\", EntryPoint = \"NavigateToSafeURI\", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static uint NavigateToSafeURINative(IntPtr context, [MarshalAs(UnmanagedType.LPWStr)] string location, [MarshalAs(UnmanagedType.LPWStr)] string target, bool checkUserInitiatedAction);
和HtmlPage.Window.Navigate(uri)进行此调用:
[DllImport(\"agcore\")]
public static int DOM_Invoke(IntPtr pBrowserService, IntPtr pObject, [MarshalAs(UnmanagedType.LPWStr)] string pszMethodName, int nArgCount, [MarshalAs(UnmanagedType.LPArray)] NativeMethods.ScriptParam[] ppParams, ref NativeMethods.ScriptParam pResult, ref NativeMethods.ExceptionInfo pExcepInfo);
    
这可能是弹出窗口阻止程序的问题。 您是否在其他任何浏览器中尝试过此操作,还是仅使用Uri进行了Navigate重载操作?
HtmlPage.Window.Navigate(uri);
    

要回复问题请先登录注册