ASP.net web api - asp.net-mvc-4

I've been reading up about MVC 4 and was interested in the web API feature.
In what scenarios would it be advantageous to use web api over a WCF Http service?

Web API provides far more access to all aspects of the HTTP interaction. It was designed from the ground up around the HTTP spec. WCF is fine if you are just using HTTP to get through the firewall. If you really want to use HTTP as an application protocol, you will find Web API much easier.

Related

web api support in all type of apps

We want to use Web API for inter-operable purposes. i mean our web api can be exposed and used in different type of apps ( Asp.net mvc, php, android, windows store/phone and ios).
We are not using wcf and prefer web api. Will it be a good choice ? we just need http and https.
Please guide the best.
if you only need support http protocol yes, web api is an excellent option, web api has a lot of features that can help you to build robust http services, and yes, I mean is a good choice.
be careful when you build yours web api service, use best practices, security in your service, and think in rest architecture, not only simple web services and you will have a true rest service
If you want to read more about this (to have a good base, not the final or only way to do this), see the rest maturity model and json api.
WCF is the best way when you need to support others protocols that only http.
Regards

Is there any advantage of Web API over WCF

I have experience in developing Restful web service using WCF. For the next project, I am considering Web API because that is the latest technology.
During my search, I found that an important reason for Web API recommendation is that it is Restful and can be accessed by HTTP protocol.
But we can also use WCF to create a restful web service that can be consumed even by mobile devices. I understand that to create a restful service using WCF, there is extra configuration involved, but besides that are there any other reasons for preferring Web API over WCF?
In other words, does Web API provide an exact subset of WCF functionality, or is there something you can do with Web API that you cannot do with a WCF service exposed as restful?

Asp web api vs wcf for point of sales application

I'm planning to develop a pos application for restaurant. Client will be using pc and mobile. Application will be used in local area connection. I'm still considering whether to go with wcf or web api. What are the advantages of using wcf/web api for the type of application i'm building?
Use WCF to create reliable, secure web services that accessible over a variety of transports.
Use ASP.NET Web API to create HTTP-based services that are accessible from a wide variety of clients.
Use ASP.NET Web API if you are creating and designing new REST-style services. Although WCF provides some support for writing REST-style services, the support for REST in ASP.NET Web API is more complete and all future REST feature improvements will be made in ASP.NET Web API.
If you have an existing WCF service and you want to expose additional REST endpoints, use WCF and the WebHttpBinding.
from the official Microsoft Documentation.
Essentially, my take on this is that WCF is much more difficult to work with, and not completely compatible out of the box with many mobile clients, so only use it if you know that it's something you need.

Difference between ASP.NET Web API and WCF regarding the Authentication mechanisms

I am making a choice between ASP.NET Web API and WCF.
I am not quite sure about the authentication part. Could some one shed some light on the differences?
I suppose there would be no actual difference under the hood. After all, the authenticaton mechanism refers to the HTTP request level on the ASP.NET engine integrated in IIS. It should have nothing to do with whether the module responding the specific HTTP request is implemented as an ASP.NET web page, WCF or Web API endpoint.
Nevertheless, there would be some differences in modelling and perhaps in configuration. WCF models the authentication mechanism as a "WCF authentication service" while Web API uses the normal security model of ASP.NET.
Use this WCF and ASP.NET security guide and this Web API security guides as a reference.
Hope I helped!

Creating a Web Proxy for Mobile Clients (HTML5 Web App)

I'm currently developing an HTML5 mobile web app for Blackberry using WebWorks that interacts with a 3rd party API.
Unfortunately i can't use the API directly from the mobile app due to the cross domain requests constraints, so i'm considering the development of a Web Proxy that interacts with the API and serves the web app.
Since I've never done such thing i would like to get some recommendations, i'm going to use Microsoft technologies (.NET) to achieve my purpose.
I'm thinking about a WCF service that makes all requests to the API and the mobile client connects to the WCF service to get the data, but i think i'll have the same cross domain requests limitation anyway so it might not work.
First, check with your third-party API provider if they support CORS. If they do, you can get around the same origin policy restrictions. Assuming they don't, you can create a facade service using ASP.NET Web API instead of WCF. ASP.NET Web API is designed from the ground up for creating HTTP services for broader reach and there is no SOAP involved.
From your ASP.NET Web API, you can make a HTTP call using HttpClient and simply pass the request to the third party API and echo the response back to your app. As you rightly said, the same origin policy restrictions will apply to this case as well but you have more control over the server side. You can implement CORS in ASP.NET Web API and that way your BB WW app can still call your web API despite being in different origins.