从 (sharepoint) Web 部件流式传输内容
如何从 Web 部件流式传输文件、html 或自定义 AJAX 响应?
我们当前快速但非常肮脏的解决方案是让 Web 部件使用某些查询参数调用当前页面,Web 部件会检查这些参数,而不是执行正常加载,而是将所需的内容写入输出并调用响应结束。
这听起来很糟糕,因为 SharePoint 可能会加载其他 Web 部件并在到达我们的 Web 部件之前执行它们的代码。
Web 部件配置有数据源设置,这意味着流上下文必须特定于 Web 部件,以便它可以获取正确的数据源设置。
How does one stream files, html or custom AJAX responses from web parts?
Our current quick-and-very-dirty solution is to make the web part call the current page with certain query parameters, which the web part checks and instead of performing normal load it writes the required things to output and calls response end.
This sounds bad since SharePoint might load other web parts and execute their code before reaching our web part.
The web part is configured with data source settings which means the streaming context must be specific to the web part so it can acquire the correct data source settings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的理解是,您几乎可以按照与普通 .Net 网站相同的方式执行此操作。
我还使用了您所描述的机制,为每个搜索“术语”提供一个 Web 部件 JSON 响应提要,我将其作为返回当前页面的参数。然后在加载期间拾取该信息,然后使用开关来确定正确的响应。
执行此操作的另一个明显方法是创建支持 Web 服务,然后您可以将其注册到母版页中的 ScriptManager。然后,您只需配置自定义 Web 部件即可调用 Web 服务方法来绘制所需的信息。通常的情况是创建一个业务对象层,其中包含一个可以可靠调用的业务对象的Web服务类。
My understanding is that you can pretty much do this in the same manners you would with a normal .Net website.
I have also used the mechanism you have described to provide a webpart JSON response feed per search "term" I provide as a param back to the current page. This is then picked up during the onload and then a switch is used to determine the correct response.
The other obvious means to doing this is to create supporting webservices which you can then register with the ScriptManager you have in your masterpage. Then you can simply configure your custom webpart to call the webservice method to draw the information required. It's usually a case of creating a business object layer with a webservice class for the business object that can be called reliably.