AsyncHttpResponseHandler
how to return JSON object in c# web service
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Mar 23, 2014, 11:00 PM EDT
Your web service method should be something like this,
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]//Specify return format.
public YourObjectType TestService()
{
YourObjectType response = new YourObject();
try
{
//Stuff goes here
}
catch (Exception ex) { responseText = "Opps wehave an error! Exception message:" + ex.Message; }
return response;
}