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.
Related
Basically I want to follow MVC Architecture. So should I use Asp.Net Web Api or Asp.Net MVC for backend development?
Does Asp.Net Web Api have MVC architecture? If does help me build Web Api using MVC Architecture in .net 6.
Based on what you've written, you have a couple options.
MVC is a front-end design pattern. For backend development, you could create a Web API project, which would give you the ability to create models and controllers similar to MVC. You would not create views with Web API as there is no UI.
Alternatively, and especially if it's a smaller project where scalability is not a concern, you could create an MVC project representing the whole app and include the backend code there rather than creating a separate backend project. In this case you'd have models and controllers driving the UI, but not the backend.
I am an MVC.NET developer but never used API web service before in an MVC project.
I just want to know like for WCF services we use different project in the application usually. Likewise, what is best practice likewise for web API services and how they work with proxy design patterns extra?
In my current application I am using WCF services but I am keen to learn if API web service can replace it and how?
yes , you can replace with API service.
For your project structure , you can refer below link content.
Implement ASP.Net Web API in ASP.Net MVC 5
http://www.c-sharpcorner.com/UploadFile/4b0136/implement-Asp-Net-web-api-2-in-Asp-Net-mvc-5/
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.
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.
A Guide to Designing and Building RESTful Web Services with WCF 3.5, this article explains the foundations of REST and how it relates to WCF. MVC uses REST as the architectural model. I am guessing one can use the .NET MVC to create web applications that have both a front end and an API point, but I am not sure if the safe way of building the API is to build it with WCF and then use it in the MVC as a controller.
Please comment if the question is not clear, I will add or modify the text.
Theres actually a third option, ADO.NET Data Servies. Anyway, here how I see them.
MVC REST: Gives you full control over how to expose your data, you have to write all the code to get it up an running tho, e.g. serialization, deserialization, all the CRUD methods etc etc. Worht metioning that this being an MVC site means you are limited to exposing your service via IIS over HTTP(S)
WCF REST: More automation than MVC, a much more solid frameowkr than MVC REST, i.e. caching, security, error handling etc (basically all the stff you'd have to write yourself using plain MVC). Being WCF, you can host this in a variety of ways (e.g WS-, TCP) etc.
ADO.NET DATA SERVICES: The quickest way to get up an running with everthing ready to use, all you need todo is configure the global.asax, however you have to use an Entity Data Model, which you many not want to.
Personally, I would use either ADO.NET DATA SERVICES or WCF REST to build an API, consue that API in MVC site and then expose that API either directly, or by passing it through another layer.
ASP.NET MVC can serve as a REST endpoint for light services work, so I guess the answer to your question depends on how you define "safe."
Clearly WCF is designed specifically for creating REST endpoints, with all of the security implications that are implied thereof, whereas ASP.NET MVC is designed to create REST endpoints which can be used by ASP.NET MVC itself.
The following article shows how to create a web service using an ASP.NET MVC controller:
Create REST API using ASP.NET MVC that speaks both Json and plain Xml
http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx
See also the following article from Phil Haack, which discusses an SDK the WCF team put together for users of ASP.NET MVC:
Rest For ASP.NET MVC SDK and Sample
http://haacked.com/archive/2009/08/17/rest-for-mvc.aspx
They are two different sets of technologies, only related by being built on .net
MVC is used to create websites and provides a model where URLs are routed to controllers and controllers deliver views to the user as the user interface.
WCF is a set of libraries in .net that are used to abstract the type of service (is it hosted in a windows service, as a webservice in IIS etc.) as well as the protocol (HTTP, TCP, MSMQ etc.) from the client and server which are communicating.
An MVC website may use WCF to connect to a web service, but that is just one of many options.