Questions tagged [wcf-web-api]

The WCF Web API project allows WCF developers to expose their APIs via HTTP. Under ASP.NET MVC4, WCF Web API has become ASP.NET Web API.

The WCF Web API project focuses on allowing WCF developers to expose their APIs for programmatic access over HTTP by browsers and devices. With the release of ASP.NET MVC4, WCF Web API is now ASP.NET Web API.

Project Links:

269 questions
414
votes
11 answers

POSTing JsonObject With HttpClient From Web API

I'm trying to POST a JsonObject using HttpClient from Web API. I'm not quite sure how to go about this and can't find much in the way of sample code. Here's what I have so far: var myObject = (dynamic)new JsonObject(); myObject.Data = "some…
Mark
  • 21,067
  • 14
  • 53
  • 71
213
votes
7 answers

Post an empty body to REST API via HttpClient

The API I'm trying to call requires a POST with an empty body. I'm using the WCF Web API HttpClient, and I can't find the right code that will post with an empty body. I found references to some HttpContent.CreateEmpty() method, but I don't think…
Ryan Rinaldi
  • 4,119
  • 2
  • 22
  • 22
99
votes
7 answers

moq objects Returns method, should return a null object

I'm developing a Web API, and one of the test I came up with is that, if client makes a GET operation with a Physical Test ID (Physical Test is the resource I'm looking for) and that physical test is not found, the web API should return a 404…
Daniel
  • 2,484
  • 4
  • 27
  • 35
58
votes
2 answers

Difference between WCF, Web API, WCF REST and Web Service?

What is difference between WCF and Web API and WCF REST and Web Service? Is WCF really so complicated that the webapi should be used? Whether WebApi can do all the work and do not take advantage of others?
Aiyoub A.
  • 5,261
  • 8
  • 25
  • 38
41
votes
4 answers

Unable to authenticate to ASP.NET Web Api service with HttpClient

I have an ASP.NET Web API service that runs on a web server with Windows Authentication enabled. I have a client site built on MVC4 that runs in a different site on the same web server that uses the HttpClient to pull data from the service. This…
40
votes
7 answers

What's the difference between WCF Web API and ASP.NET Web API

I've done a bit of work in the past using WCF WebAPI and really liked a lot of its features, I'm just playing with ASP.NET Web API at the moment and it seems completely different (IE completely removed from WCF). Does anyone know which features of…
undefined
  • 33,537
  • 22
  • 129
  • 198
40
votes
3 answers

Programmatically set InstanceContextMode

Is there a way to do this ... [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] ...programmatically? The reason is that I want to pass in an instance of my service directly into my self-hosting helper class when integration…
Antony Scott
  • 21,690
  • 12
  • 62
  • 94
37
votes
11 answers

ASP.NET Web API binding with ninject

I have just installed the mvc4 rc update and I am trying to build an api application with little luck. I am using ninject but cant get my controllers to load. I keep getting an error Type 'Api.Controllers.ConsumerController' does not have a default…
Diver Dan
  • 9,953
  • 22
  • 95
  • 166
28
votes
5 answers

Web services API Keys and Ajax - Securing the Key

This is probably a generic security question, but I thought I'd ask in the realm of what I'm developing. The scenario is: A web service (WCF Web Api) that uses an API Key to validate and tell me who the user is, and a mix of jQuery and application…
crucible
  • 3,109
  • 2
  • 28
  • 35
27
votes
5 answers

HttpClient authentication header not getting sent

I'm trying to use an HttpClient for a third-party service that requires basic HTTP authentication. I am using the AuthenticationHeaderValue. Here is what I've come up with so far: HttpRequestMessage request = new…
Ross
  • 2,448
  • 1
  • 21
  • 24
26
votes
1 answer

Return either xml or json from MVC web api based on request

Given the following webapiconfig; config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); and this controller; public…
ChrisBint
  • 12,773
  • 6
  • 40
  • 62
25
votes
4 answers

WCF Web API vs ASP.NET MVC JSON web services

What is the advantage of using new WCF Web API over ASP.NET MVC 3 to expose a lightweight JSON Web service layer? I like Web API in many ways, but the drawback is that it doesnt work on mono, while MVC 3 does. What are the major differences between…
adrin
  • 3,738
  • 8
  • 40
  • 60
23
votes
1 answer

Is it necessary to close the Stream of WebInvoke method

I have a service interface with a method that has a parameter of type Stream. Should i close the stream after i have read all data from this stream or is this done by the WCF Runtime when the method call is completed? The most examples i have seen,…
Jehof
  • 34,674
  • 10
  • 123
  • 155
21
votes
2 answers

System.Net.Http.HttpClient caching behavior

I'm using HttpClient 0.6.0 from NuGet. I have the following C# code: var client = new HttpClient(new WebRequestHandler() { CachePolicy = new…
NiklasN
  • 559
  • 1
  • 7
  • 12
21
votes
3 answers

Dependency Injection in WebAPI with Castle Windsor

I want to implement Dependency Injection in WebApi application using Castle Windsor. I have following sample code - Interface - public interface IWatch { { DateTime GetTime(); } } Following Watch class implements IWatch Interface…
Sumit Deshpande
  • 2,155
  • 2
  • 20
  • 36
1
2 3
17 18