简体   繁体   English

需要有关通过 ASP.NET/WCF 将数据获取到 Silverlight 应用程序的指导

[英]Need guidance on getting data to Silverlight app via ASP.NET/WCF

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.基本上我正在开发一个 asp.net (4.0) 应用程序。 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.一个 web 表单代表一个报告,它分为两部分: - 一个 div,其作用类似于一个控制面板,其中包含为查询提供参数的文本框、组合框、日历等,以及一个用于获取数据的按钮。 - a div that holds the silverlight control host. - 一个包含 silverlight 控制主机的 div。 The silverlight app only contains a custom datagrid control. silverlight 应用程序仅包含自定义数据网格控件。

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.因此,正如您想象的那样,用户提供参数值并单击按钮将数据获取到 silverlight 应用程序的自定义数据网格控件中。 -I know what you're probably asking yourself, why don't I just add the controls to the silverlight app and use RIA services. -我知道您可能会问自己,为什么不将控件添加到 silverlight 应用程序并使用 RIA 服务。 Without going into too much detail, we want a newer datagrid that we can slap into some of our existing asp.net pages.无需过多详细说明,我们需要一个更新的数据网格,我们可以将其添加到我们现有的一些 asp.net 页面中。

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.我想我想做的是有一个 wcf 服务,它只向页面上的 silverlight 客户端发送数据。 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.让我明确一点,我不需要请求/回复消息交换模式,因为 silverlight 客户端不会发出任何请求。 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.在完成此任务的“任务”中,我找到了有关双工消息传递的示例/教程,我认为如果我可以将 asp 页面设置为服务的客户端并将 silverlight 应用程序设置为同一服务的客户端,这些示例/教程可能会很好用。 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.用户点击按钮,asp页面的服务引用调用服务获取数据,然后将数据发送给silverlight客户端。 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?它会更新他们的两个 sl 应用程序吗? 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?所以我的问题是任何人都可以提供任何建议、链接或其他资源来解决这种情况吗?

First off, I don't think you need Silverlight.首先,我认为您不需要 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.有很多很棒的 UI 控件,例如Telerik RadGrid ,您可以放入现有的应用程序并在一两个小时内启动并运行。

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.话虽如此,如果你真的想完成这项工作,你需要的是在浏览器和 Silverlight 中都可以工作的 pub/sub。 Take a look at PubNub .看看PubNub You get 5,000 messages per day for free, and works in virtually any client (phone, Silverlight, browser, etc) with a simple API.您每天免费获得 5,000 条消息,并且几乎可以在任何客户端(电话、Silverlight、浏览器等)中使用简单的 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.基本上,您的 Silverlight 客户端将订阅“通道”以在过滤器参数更改时收到通知,并且您的表单将通过 JavaScript 或服务器端将消息发布到此通道,告诉订阅者(在您的情况下为 1)更改的过滤器值. When the Silverlight client is notified, it would make a request for data via WCF.当 Silverlight 客户端收到通知时,它会通过 WCF 请求数据。

Bit of a hack though.不过有点hack。 I would encourage you to drop the Silverlight and use an AJAX grid.我鼓励您放弃 Silverlight 并使用 AJAX 网格。 Hope this helps!希望这可以帮助!

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

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