I have a web site that needs data to be pushed to it. Unfortunately, I'm not aware of any other methods besides using HTML 5 WebSockets (I can't garauntee my clients will have HTML5 browers) and Comet (I'm not using java/tomcat).
I am not a big fan of using server-side ASP.NET for this particular project, and would prefer to use ASP.NET MVC or something like it. Is it possible to tie JavaScript in with a duplex service?
Well actually you can leverage the pollingduplex binding used for silverlight clients in javascript. There is an interesting blog post on this by tomek over here: http://tomasz.janczuk.org/2009/07/pubsub-sample-using-http-polling-duplex.html
Related
I need to calling our C# Methods from another server to perform some Action. I use C# in both servers. One is our Service Application, another one is a WPF application where I consume my Service.
Prefer I use a WCF or WebAPI service for Service Application?
Most People prefer to use Web Api, but web doesn't expose metadata for creating proxy by service.
which one is simple and better choose?
You may use either WCF or WebAPI, if multiple platforms (Mobile, Web, Other Service) are going to interact with your service, then I would recommend Web API, otherwise you may use WCF. Similar discussion has already happened in another question, please refer this link, hope this will be useful
Getting a web service and using android to consume them?
I have created a silver-light website.
Silver-light has part for the client side and part for the server side.
Now, I want to crate another site in .net MVC 4.
I can't really understand two things.
The first is, where the site will be executed?? Client side or server side??
for example if i have a LINQ function in the controller, where it will be executed??
The second is, may i use WCF like in silver-light?? Or i can just add .edmx file(ado.entity file) in the project??
Yes you can able to use WCF service in silver-light application. You must need to add the reference of the WCF application
The answer to your first question is that MVC is a server-side technology. You can utilize JavaScript and other methods to utilize the technology for client-side functionality, but it requires the controllers, views and models to execute on the server.
The answer to the second question is that WCF can be used just like Silverlight in MVC, although depending on how you utilize it, depends on if it is consumed on the client-side or not. If you access WCF through the Controller, its done on the server side. If you consume it through AJAX/jQuery then you are handling it through the client-side.
I am developing a application that is using backbone.js for most of the front end logic and was thinking of using sqlite for storage, but i have run into a few complications with it and need to switch to another NoSQL database.
I see on ravendb's site that it was created in C# and you need a .net compiler. Most of the docs are for ASP MVC type application. I can not go this root because we are developing this as a tablet application with no microsoft based technologies on the client side ( because we want it to work with android and apple )
The server however will be .NET and so i figured this might be do able. Just wondering if this is worth pursuing and if anyone has had any experience using ravendb? Or should i go for mongodb?
It is possible to expose RavenDB directly to a JavaScript application, sure. But it's usually not recommended. The main reason is security, but there are many other reasons to have a middle-layer.
For example, you often need a server-side location to perform application logic. Not everything can be done in the database itself, and if you do it all in the application then you will probably send a lot more data to the app than it really needs. Over the internet, that could mean a slow app.
The route many people take, is to use ASP.Net WebAPI, or ServiceStack, or another similar framework. This gives you a way to expose REST endpoints that your JavaScript app can call. You can connect to RavenDB from there.
Also, you seem to have the misconception that if you used ASP.Net MVC on the server that you couldn't target Apple or Android. That's just false. Whether you use a SPA approach or a traditional approach, you are delivering standards-based content, such as HTML, CSS, JSON and JavaScript.
Yes, You can use it. Actually RavenDB's server is a RESTful web service, which means you can work with it with any kinds of HTTP clients. These clients should be able to issue standard HTTP verbs like GET, PUT, DELETE etc.
ASP MVC is server side. I still at a loss as to why you would want to expose your db to a clientside piece. It is completely worth doing in a server side piece, but do not expose something like a db directly to your client.
I am new to ASP.NET Web API. Can anyone please tell me
Why we need Web API?
How it differs from rest full api from MVC ?
When to use MVC4 web api ?
What is restful api in MVC
WebAPI is based on MVC, but has some subtle differences. You need to understand that WebAPI is a separate thing from MVC, and does not require MVC. You can install WebAPI separately, and you can uninstall it from the default MVC templates.
It's true, MS could have built WebAPI directly into the MVC Controllers, but they chose to keep API Controllers separate from MVC Controllers because they really are different ways of dealing with requests and responses.
Examples of things you can do in WebAPI that you can't (or at least not as easily) in MVC include:
Content Negotiation
This allows the calling client to choose the format that data will be returned in, such as XML or JSON.
OData support
This allows the caller to "filter" results on the server without the service method having to specifically support it. For instance, if you want to sort the results by first name, then this can be done simply by specifying OData query parameters
WebAPI provides a lot of power for dealing with data result sets. MVC does not provide that kind of functionality.
You would tend to use WebAPI for things like Ajax requests, or web service based requests that do not require the complexity of WCF.
RESTful API's are not specific to MVC or WebAPI. They're simply a philosophy for how you design your HTTP requests in a service. There's a lot to it really, but I won't go into it.
WCF team merged at Microsoft with MVC team. WCF is not going away, but for simple RESTFUL service call, the MVC Controller were a match made in heaven, and the modification to it allowed for a very easy Web API.
While many of us feel WCF is relatively easy, there are many who fear it and/or don't have/take time to learn it, thus they a. still use ASMX, b. still never adopted services, or NOW with Web API, are c. Very excited that they can very easily get up and running with restful web services.
So really it is a matter of comfort level, adaptation, ability to change and the Web API does have its place. It cannot replace WCF as WCF has advanced configurations with all the bindings and ability to do SOAP and not just REST, which many applications still NEED to have SOAP protocol.
MVC is optimized to serve information to a web browser client. If your client is something else, Web API will make your life easier over the long term.
Web API is a from the ground up re-write of the web stack. At the core it is much cleaner and more flexible than the 12 year old infrastructure that MVC is built on top of. Web API does not yet have the same level of tooling, add-ons, plugins as MVC, but that will come.
I'm new to WCF RESTFull services developpment and I'm looking for some usefull information and your experience feedback about using webHttpBinding compared to the new WCF Web API http://wcf.codeplex.com/.
What I'm looking for is to know about the shortcomings of webHttpBinding and therefore why to use the new Web api and especially what problems the new API resolves.
If you could point me to some blog posts comparing both of them or just talking about the problems when using webHttpBinding I would appreciate. Thank you in advance.
Main shortcomings I would say is that the webhttpbinding makes it difficult to handle HTTP specific concerns. It works great if all you are doing is passing an object over HTTP that is serialized into XML or JSON and which may be transported over different formats.
HTTP is much more than a simple transport protocol for XML and JSON, it is an application layer protocol with rich semantics. Web API is specifically targetting folks that want to build systems over HTTP that fully levergage HTTP's richness.
Web API embraces that HTTP Resources can have a multitude of representations based on the needs of different clients. One end of the spectrum could be a dumb browser that just talks to a service using a Form url encoded post and a GET, while the other end could be a more rich client that uses Atom/OData or a hypermedia based media type.
Web API embraces that there are other HTTP specific concerns like conneg, etags, etc which allow better leveraging intermediary web servers.
Web API is designed with more testability in mind, thus you can address working with HTTP messages or other concerns in a more testable manner.
Web API has a more simplified configuration story.
You can read more about the rationale here: http://blogs.msdn.com/b/endpoint/archive/2010/11/01/wcf-web-apis-http-your-way.aspx
The most significant difference for me is the change in programming model. You no longer write 'services' which expose 'operations' bound to HTTP idioms (GET, POST etc.). With Web APIs you create 'resources' (POCOs) with which your clients can interact.
Web APIs seem to be better at handling various custom media types (like PNG images for example).
Last but not least, Web APIs are far better suited for automated testing. For instance, you no longer have to use static context classes to access HTTP concepts such as response codes. You use POCO request and response classes which can be easily instantiated in automated tests using old-style new() operator.
I agree with Ladislav that Web APIs are just a preview now and building application on top of it can be both risky and forbidden by the means of license agreement (but I haven't checked that).
Have you considered #serialseb's OpenRasta? It is stable and offers very nice programming model for building RESTful services.
The Web API is something like possible future of REST development in WCF. It is just preview which can significantly change before final release (probably in next version of .NET framework). So if you want to build production REST service you should use webHttpBinding.
Available information about Web Api can be found for example on .NET Connected Framework team's blog and on the site you mentioned. It is simplification and extension of current REST API.
Web API provides a REST-friendly HTTP based API. Web API uses the patterns of MVC and is going to be very familiar to ASP.NET MVC developers. Web API can leverage the capabilities of HTTP as an application layer protocol, returning resources in multiple representations (XML, JSON, HTML etc.) according the the client's request headers.
On the other hand WCF webHttpBinding uses the patterns of WCF, and is going to appeal more to the WCF developer - ServiceContracts, OperationContracts, comprehensive (or overweight, depending how you look at it, config file), ability to self-host outside of IIS.
One of the things I like about Web API is the ability to use dynamic types to escape the constraints of the type system. I also like the default exception behavior in Web API - contrast WCF webHttpBinding where, by default, exceptions bubble up as HTTP 500 + an HTML payload (yuk!).
Its nice to have the choice between two excellent technologies here. I wouldn't describe Web API as 'newer' or 'better' that WCF, as this implies its a replacement technology and that WCF webHttpBinding is legacy, which I don't believe is true.
I chose to use WCF webHttpBinding recently to expose a JSON API for an existing WCF SOAP service. I believe it was a good choice because it fitted that style of that existing solution and minimized the amount of change required.