简体   繁体   English

如何将链接转换为源以在Silverlight中流式传输?

[英]How to convert link to source to stream in silverlight?

如何将链接转换为源(包含URL的字符串)以在Silverlight中流式传输?

You mean you have a string containing the URL of a source, and you want to download the contents of that source? 您的意思是您有一个包含源URL的字符串,并且要下载该源的内容?

Use WebRequest.Create to create a request object, then call BeginGetResponse on that request object. 使用WebRequest.Create创建一个请求对象,然后对该请求对象调用BeginGetResponse。 In the async callback, call EndGetResponse to get the response object. 在异步回调中,调用EndGetResponse以获取响应对象。 Then call GetResponseStream on the response object to get the data stream. 然后,在响应对象上调用GetResponseStream以获取数据流。

Note that the URL must contain the protocol eg http: or https:. 请注意,URL必须包含协议,例如http:或https:。 Note that Silverlight's WebRequest class does not support non-HTTP protocols (such as FTP) out of the box. 请注意,Silverlight的WebRequest类不支持即开即用的非HTTP协议(例如FTP)。

If you know the data format, eg a WCF service or ADO.NET data service, there may be proxies or wrappers that will insulate you from this low-level detail. 如果您知道数据格式,例如WCF服务或ADO.NET数据服务,则可能有代理或包装程序将您与这些低级详细信息区分开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM