Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 20, 2012 12:19 PM by RajeshKalis
Oct 31, 2012 01:36 PM|LINK
I need some help on calling web api controller actions from C#.net client application.
I have created a web api controller class LibraryController.cs and added the following code in this class.
public System.Web.Mvc.JsonResult GetAllBooks()
System.Web.Mvc.JsonResult jsonResult = new System.Web.Mvc.JsonResult();
jsonResult.Data = <List<Book> object>;
But, how can I call this from C#.net code with HttpClient object? I need to call this action from both jquery ajax and C#.net.
Oct 31, 2012 02:21 PM|LINK
Nov 02, 2012 06:50 AM|LINK
Thank you for your reply, but I did not find any solution from those samples.
Nov 06, 2012 05:16 PM|LINK
Please go throught these examples. If you are working in MVC4 i will recommend use asp.net WebAPI .
Nov 08, 2012 06:43 AM|LINK
Sorry to say, these samples did not solved my problem.
Nov 08, 2012 02:03 PM|LINK
Something like this:
public class MoviesService
const string baseUrl = "http://localhost:2100/api/movies1/";
public Task<IEnumerable<Movie>> GetAllAsync()
var client = new HttpClient();
var task = client.GetStringAsync(baseUrl);
return task.ContinueWith<IEnumerable<Movie>>(innerTask =>
var json = innerTask.Result;
Nov 20, 2012 12:19 PM|LINK
I have created a new thread with clear example for my requirement.
Please give me your suggestions.