do you know of any available architectural pattern where the most of the code could be shared between Silverlight and ASP .NET UI? I understand that Silverlight won’t work very well with MVC (although people are blogging on how they achieved this in fact what they did wasn’t pure MVC) and same applies to ASP .NET MVVM.
However, I’m pretty sure there is a pattern where all of your business and data layers could be re-used by both Silverlight and ASP .NET app?
The example of when this would be needed is if we created a web application using Silverlight for desktops and asp .net for mobile devices and iPad, assuming that everything but UI would be the same.
You could simply creat a business logic layer assembly that would be used by both the Silverlight and ASP.NET versions of the application, the UI would be different but they'd both be using the same business logic or whatever you want to call it. The trick however is that Silverlight is a client technology so the server-side piece would house all that shared logic and you'd need to then interface that through a web-service your client could talk to, but that goes without saying when it comes to Silverlight/client-side technologies.
Contrary to what you've heard: Silverlight works great with MVC!
As far as sharing code the simplest answer is to have a single implementation of your data layer and business objects in the MVC application and then expose this to your Silverlight application via web services.
Ideally this means that the only code in your Silverlight application is UI specific...
RIA Services works with both Silverlight and ASP.Net and provides both client and server validation via member attributes. Code is shared auto-magically between sever and client apps.
You can use WCF and/or Ria services for data layers.
Related
I did some research around but I have some doubts still about following topic...
I have Silverlight/RIA Services project that needs to have ASP.NET MVC look as well as WebAPI for some different clients.
So my question is following
Can we use somehow RIA Services with ASP.NET MVC 5?
And if not what is a painless way to represent all existing logic in ASP.NET MVC?
Thank you!
Ria services have nothing to do with look and feel.
A Silverlight app or a non plugin, which uses RIA services can be hosted in a web page created using ASP.Net.
Can we use somehow RIA Services with ASP.NET MVC 5?
Yes.
RIA services which could be used by an asp.net backend would not gain the benefit of RIA services because changes made in the backend end are not generated forward to an application such as a Silverlight plugin. It just becomes another way of accessing data.
For a new SPA Web App which will initially have very little user interaction and incrementally will have new features which will require lot of user interaction. This app is targeted for mobile devices. I am using this weird combination of technologies.
AngularJS + jQuery Mobile - for Client Side - MVC framework + SPA framework.
ASP.NET MVC - Server side MVC Framework - which seems unnecessary.
WCF REST Services (from 3rd party) - Do not have any control here, just consuming it. These services returns JSON data. All business logic resides here. Application do not have any feature outside of this.
Once application loaded at client side all service calls will happen from AngularJS to REST Services.
The main role of ASP.NET MVC, is just initial request load only. Even user session is handled between AngularJS and REST services.
But I foreseen eventually application will be complex to handle all the stuff at client side. So looking to push some complex processing which is easy and efficient to get done using ASP.NET MVC and .NET Sandbox. I cannot ask REST Service to do this because as i mentioned it is 3rd party.
In dilemma,
1. Should i maintain user session on server side as well?
2. How can i utilize ASP.NET MVC best possible way?
Thanks for any suggestions.
Your dilemma is justified and valid. When I go with angularJs, my big question is , do i need to csthml file or shall i use the html file.
I always go with cshtml, hoping that in future there may be scenario where i may have to leverage the server side capabilities of the mvc.
Currently I am working on the same combination of technologies stated above and with modularity of arranging js codes(angular controllers) i don't see any issues. I am bit curious on what complexities you would be adding to the contoller as you have stated that all your business logic is done by the third partly controller.
If you are looking for security aspect, I would suggest you to write a custom actionfilter which uses httpmodule to do the custom security handling.
With MVC , sessions should be a BIG NO . At lease in my organisation it so.
I have an asp.net mvc3 application built with RavenDB and I want to be able to access the data via an external HTML5 mobile app. I'm thinking of exposing methods via WCF or via MVC controller action methods? Which option is best?
Ok, I have faced similar situation a while ago. This the way I have handled it, I have directly exposed Controller urls to the mobile application clients. Bascially it will help you in reducing the burden of maintaining two code bases and helps you to reuse existing functionality. Even if you go with WCF you need to expose with REST to make HTML5 client developer life easy.
This is the why microsoft released ASP.NET MVC 4 Web Apis to avoid confusion among developers which way to go in these scenarios. So that your services are device agnostic and easily testable.
Since you've already built the app in MVC3, I'd recommend a JsonResult action on an MVC Controller: http://www.asp.net/ajaxlibrary/jquery_json_data_from_controller.ashx
So I am looking into solutions for developing a Silverlight web app, and right now ASP.NET MVC and WCF RIA have caught my eye.
Should these two be used in conjunction with one another? Or does the 'MC' in MVC play the role of the RIA services?
Would it be redundant to use both in the same web application?
Thanks.
WCF RIA Services work great with Silverlight. So you just need to host your SL application somewhere, a static HTML page could work just great. You don't really need ASP.NET MVC.
Asp.net MVC is basically used for visualized applications. WCF RIA Services are API oriented and are supposed to be used with Silverlight. Or even preferred.
You could of course write an Asp.net MVC application that would return Json results for every request but what would be the point in doing that? In that case (if you would want to write all the code manually) you'd rather go with a standard WCF service instead.
WCF RIA Services are the fastest way to getting to your data in developer's perspective. Learn and use it. No better way basically.
I recently got into Silverlight development. So far I've managed to create a single Silverlight XAML view which pulls in data from an SQL Server Database using the ADO.Net Entity Framework and displays the data in a Silverlight DataGrid. I can also perform simple editing and update functionality on the data and persist it back to the database. At this point my understanding fails. From what I gather, the Silverlight Client Application is hosted inside an ASP.NET or ASP.Net MVC web application. Normally I would just build a website using ASP.Net MVC and use a few jQuery controls, etc., to spice up the interface on each view. How do I go about using these different Silverlight XAML views that I create in my ASP.Net MVC application like they were MVC Views? Have I totally missed something here?
RIA Models
There are two different models for integrating Silverlight (or any RIA technology) into your website:
Entire Silverlight application hosted in simple website
Silverlight controls integrated into a website with other interaction (forms, jQuery, etc.)
Either model works well, it's up to you to decide which works better in your scenario.
Silverlight communication with the server
Your Silverlight application is a plugin hosted in a browser, so it's best to think of it like jQuery or other client-side code. There are several ways to communicate back to the server:
RIA Services
ADO.NET Data Services
Custom WCF service
Other REST / SOAP communications you build yourself
Silverlight supports WebClient and HttpWebRequest, so you can get as low-level as you'd like in your client-server communication. I really recommend looking at RIA Services since it handles not only the communications, but also the validation rules.
Silverlight integration with HTML / Javascript
Silverlight can both call and be called from Javascript via the HTML bridge. This means that your Silverlight components can be as closely integrated with your web-page as you'd like. Silverlight can also directly interact with the DOM - setting and reading form values, changing CSS properties, etc. You can do just about anything you'd do in Javascript via the HTML bridge if you'd like.
In order to update your data model from your Silverlight application (which is running on your client's machine) is to utilize WCF (Windows Communication Foundation). Your Silverlight application will communicate to your server using WCF, and none of that has really anything to do with how you're serving up your Silverlight app (whether you're using Webforms or MVC).