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

Silverlight的HtmlPage.Window.Navigate和HyperlinkBut​​ton之间的区别?,第1张

概述我正在尝试让我的Silverlight 4.0应用程序在用户点击某些内容将其带到其网址时启动相关程序文件的文件扩展名,但我是否有使用 HtmlPage.Window.Navigate或HyperlinkBut​​ton的不同体验. 我的网址是我资源的RESTful网址,例如“HTTP://…/objects/object-1/package”.该URL实际上是一个ASP.NET MVC 2控制器, 我正在尝试让我的Silverlight 4.0应用程序在用户点击某些内容将其带到其网址时启动相关程序文件的文件扩展名,但我是否有使用 HtmlPage.Window.Navigate或HyperlinkBut​​ton的不同体验.

我的网址是我资源的RESTful网址,例如“http://…/objects/object-1/package”.该URL实际上是一个ASP.NET MVC 2控制器,它使用自定义扩展返回zip内容.也就是说,http响应头看起来像:

http/1.1 200 OKServer: ASP.NET Development Server/10.0.0.0Date: Wed,13 Apr 2011 17:22:19 GMTX-AspNet-Version: 4.0.30319Content-disposition: attachment; filename=object-1.pkgtransfer-encoding: chunkedCache-Control: privateContent-Type: application/zipConnection: Close

当我使用超链接按钮时,Internet Explorer会提示我打开,保存或取消.当我选择Open时,它会打开我与* .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社区可以确认或否认这个问题.

解决方法 有一篇简短的文章 here对这个问题有所了解 – 我发现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);
总结

以上是内存溢出为你收集整理的Silverlight的HtmlPage.Window.Navigate和HyperlinkBut​​ton之间区别?全部内容,希望文章能够帮你解决Silverlight的HtmlPage.Window.Navigate和HyperlinkBut​​ton之间的区别?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1007410.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存