需要有关通过 ASP.NET/WCF 将数据获取到 Silverlight 应用程序的指导
首先感谢您的帮助。我进行了广泛的查找,但没有找到确定的解决方案,所以我在这里......
基本上我正在开发一个 asp.net (4.0) 应用程序。一个 Web 表单代表一份报告,分为两部分: - 一个类似于控制面板的 div,其中包含文本框、组合框、日历等,它们提供查询参数和获取数据的按钮。 - 一个包含 silverlight 控制主机的 div。 silverlight 应用程序仅包含自定义数据网格控件。
因此,正如您所想象的那样,用户提供参数值并单击按钮将数据获取到 silverlight 应用程序的自定义数据网格控件中。 - 我知道您可能会问自己,为什么不将控件添加到 silverlight 应用程序并使用 RIA 服务。在不涉及太多细节的情况下,我们需要一个更新的数据网格,我们可以将其放入一些现有的 ASP.NET 页面中。
我不知道对于这样的事情最好的做法是什么。我进行了广泛的研究,考虑了几种选择,甚至进行了尝试(但没有成功)。
我想我想做的是有一个 wcf 服务,只将数据发送到页面上的 silverlight 客户端。 让我明确一点,我不需要请求/回复消息交换模式,因为 silverlight 客户端不会发出任何请求。 在我完成此任务的“追求”中,我找到了有关双工消息传递的示例/教程,如果我可以将 asp 页面设置为服务的客户端并将 silverlight 应用程序设置为同一服务的客户端,我认为这些示例/教程可能会很好用。 用户点击按钮,asp页面的服务引用调用服务来获取数据,然后将数据发送到silverlight客户端。 我担心的一个问题是,我找到的所有教程都会将消息发送给所有客户,那么如果两个人同时访问该网站怎么办?它会更新他们的两个 sl 应用程序吗?我如何瞄准合适的客户?
所以我的问题是任何人都可以提供任何建议、链接或其他资源来解决这种情况吗?
First of all thank you for any help. I have looked extensively and haven't found a sure solution, so here I am...
Basically I am developing an asp.net (4.0) app. One webform represents a report and is divided into two pieces:
- a div that acts like a control panel which contains textboxes, comboboxes, calendars, etc. which provide parameters for a query, and a button to get the data.
- a div that holds the silverlight control host. The silverlight app only contains a custom datagrid control.
So, as you would imagine, the user provides values for the parameters and clicks the button to get the data into the silverlight app's custom datagrid control.
-I know what you're probably asking yourself, why don't I just add the controls to the silverlight app and use RIA services. Without going into too much detail, we want a newer datagrid that we can slap into some of our existing asp.net pages.
I don't know what is the best practice for something like this. I've looked extensively and there are several options I have considered and even got my feet wet experimenting (with no success).
What I think I would like to do is have a wcf service that only sends data to the silverlight client on the page.
Let me be clear that I do not need a request/reply message exchange pattern because the silverlight client isn't going to be making any requests.
In my "quest" to accomplish this I have found examples/tutorials on duplex messaging which I think might work well if I can set the asp page as a client to the service and the silverlight app as a client to the same service.
The use clicks the button and the asp page's service reference calls the service to get the data and then in turn it sends the data to the silverlight client.
One concern I have is that all of the tutorials I have found send the messages to all of the clients, so what if two people are visiting the site at the same time? Would it update both of thier sl apps? How would I target the right client?
So my question is can anyone provide any advice, links, or other resources for a solution to this scenario?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我认为您不需要 Silverlight。有很多很棒的 UI 控件,例如您可以使用的 Telerik RadGrid可以放入您现有的应用程序中,并在一两个小时内启动并运行。
话虽如此,如果您确实想让这项工作成功,您需要的是既能在浏览器中又能在 Silverlight 中工作的 pub/sub。看看 PubNub。您每天免费获得 5,000 条消息,并且可以通过简单的 API 在几乎任何客户端(手机、Silverlight、浏览器等)中工作。
基本上,您的 Silverlight 客户端将订阅一个“通道”,以便在过滤器参数更改时收到通知,并且您的表单将通过 JavaScript 或服务器端向此通道发布消息,告诉订阅者(在您的情况下为 1)更改的过滤器值。当 Silverlight 客户端收到通知时,它将通过 WCF 发出数据请求。
不过有点黑客行为。我鼓励您放弃 Silverlight 并使用 AJAX 网格。希望这有帮助!
First off, I don't think you need Silverlight. There are a ton of great UI controls out there like Telerik RadGrid that you could drop into your existing app and be up and running in an hour or two.
Having said that, if you really want to make this work, what you need is pub/sub that works both in the browser and in Silverlight. Take a look at PubNub. You get 5,000 messages per day for free, and works in virtually any client (phone, Silverlight, browser, etc) with a simple API.
Basically, your Silverlight client would subscribe to a "channel" to be notified when the filter parameters change, and your form would publish messages to this channel, either through JavaScript or server side, telling subscribers (1 in your case) of changed filter values. When the Silverlight client is notified, it would make a request for data via WCF.
Bit of a hack though. I would encourage you to drop the Silverlight and use an AJAX grid. Hope this helps!