ASP.NET Web API HttpClient on 3.5 or 2.0 application?

I like the HttpClient in ASP.NET Web API. Can I use it in 3.5 or 2.0. I mean in any .NET Framework application versions before 4.0. Actually, I have a ASP.NET Web API app in ASP.NET 4.0. I need to consume this app from a device built in 3.5 framework. I know I can use WebClient/WebRequest, But It will be great If I can use HttpClient stuffs.

Upvotes: 2

Views: 8531

Answers (2)

Garrett Fogerlie
Garrett Fogerlie

Reputation: 4458

According to this,

WebAPI requires .net 4. You can't use it on .net 3.5 (sp1 or not).

You also can't use the preview releases for production code as you don't have a "go-live" license, so even if you could get it to work, it wouldn't be legal. You need to use at least the ASP.NET WebAPI Beta to get a go-live license.

And according to this,

The HttpClient library was initially introduced in the "WCF REST Starter Kit" project, so you can download it from there. This project isn't supported anymore (most of its functionality has either made it into the framework or is now part of the Web API project), but the HttpClient from there works quite well.

Upvotes: 3

Sando
Sando

Reputation: 667

Ideally your HttpClient project should be completely separate from your service project. I would keep the service(s) project as it is in 2.0 or 3.5 and create a 4.0 project with HttpClient and make HTTP calls.

The only minor issue here is implicit model binding. Here you can use a Model dll or consume the 3.5 model classes in the 4.0 client project. But the JsonObject binding should also work seamlessly for json resonses.

Upvotes: 1

Related Questions