suppose this is my class which i like to return from my action
public class Response { public bool IsSuccess { get; set; } public string Message { get; set; } public object ResponseData { get; set; } public Response(bool status, string message, object data) { IsSuccess = status; Message = message; ResponseData = data; } }
OR
public class Response<T> { public bool IsSuccess { get; set; } public string Message { get; set; } public IEnumerable<T> ResponseData { get; set; } public Response(bool status, string message, IEnumerable<T> data) { IsSuccess = status; Message = message; ResponseData = data; } }
now this way i am wrapping output into response class and return from web api action
[HttpGet, Route("GetAll")] public HttpResponseMessage GetAllCustomers() { var Response=new Response(true, "SUCCESS", repository.GetAll()); return Response; return Request.CreateResponse(HttpStatusCode.OK, Response); HttpResponseMessage response = Request.CreateResponse<Response>(HttpStatusCode.OK, Response); return response; }
but json is not coming to client. where i made the mistake in code ?
i need to get json when i will invoke the above action from fiddler. please guide me how to fix the above code a result right json of Response class should return to client?
please give fresh and rectified working code copy of above one. thanks