I have an Asp.net MVC application which uses html5 and jquery on the client side. Management want to experiment with Silverlight as they feel it will give the end user the impression they are running a desktop application rather than web based application.
What I want is to create a silverlight version of the application but unlike a MVC application where html views are returned I really want to have data just returned and consumed by the silverlight application. So each time I go to a new page in the silverlight application only the data i开发者_如何学Pythons returned to populate it (I do not want to return a xaml page which has the data embedded in it). So all my application logic will be in the silverlight application.
Since our application will be a multi-user system, one of the requirements is that when showing a grid of data in the silverlight application the grid must be periodically updated as other users add and remove records. Currently with the MVC app I have a timer which updates the grid with an Ajax call every few seconds.
I am not sure if I can reuse the mvc controllers and actions and just return data or whether I should go with RIA services as it may provide me with other richer functionality.
JD
RIA does provide with richer functionality, but IMO lacks the very reusability (interop with jquery for example) you'd need here. See Tim Heuer's blog on how to use Silverlight as a View with MVC here, and maybe add an extra parameter to your call's like (?mode=sl) and check for it in your controllers, so gather all your data you'll need for your views then
if (mode == "sl") return Json(data);
else return View(data);
Of course, life is not this simple, you'll have problems with Child Actions, ViewModels, etc. But it's a start.
On the other hand if you're just doing CRUD operations, and have written almost no business logic into your controllers, then fire away with RIA! IMO, the most important thing of them all is DRY!!! (Don't repeat yourself) So if you have lot's of code in Controller then don't rewrite it around RIA in SL again!
Both? :)
Create one or more repositories to contain your data IO and business logic and let your MVC actions and domain service methods surface what's needed.
精彩评论