As mentioned in the question, How to make asp.net page returns data in JSON format ?
- 
        Check out the answer in this SO post: stackoverflow.com/questions/191881/…WraithNath– WraithNath2012-03-28 08:36:44 +00:00Commented Mar 28, 2012 at 8:36
- 
        Thanks, but I m sorry to duplicate the question, please can yo tell me how to search the required question before posting it ?Bader– Bader2012-03-28 08:38:28 +00:00Commented Mar 28, 2012 at 8:38
- 
        Are you using MVC or webforms?AlexC– AlexC2012-03-28 08:39:05 +00:00Commented Mar 28, 2012 at 8:39
- 
        @AdhamEnaya - When typing the question to post on SO, previous questions will be displayed, you can also use the search bar at the top of SO. In this case I just googled it and a stack overflow page came up with the answer :) I didnt want to duplicate the question which is why I just commented :)WraithNath– WraithNath2012-03-28 08:41:42 +00:00Commented Mar 28, 2012 at 8:41
- 
        I think the most relevant SO question is stackoverflow.com/questions/5364343/…AlexC– AlexC2012-03-28 08:47:40 +00:00Commented Mar 28, 2012 at 8:47
3 Answers
Insteed of response with HTML you can response with some JSON. What I think you want to do is adding an interface which can response with JSON.
With .NET you can use webservice which response in JSON format, have a look on this article:
http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
Comments
That depends on whether you are using webforms or MVC.
For webforms you can just write out the data that you want:
Response.Clear(); // not needed it you have an empty page markup
Response.ContentType = "application/json";
Response.Write("{\"hello\":\"world\"}");
Response.End();
For MVC you can use the Content method in the action for the page:
return Content("{\"hello\":\"world\"}", "application(json");
Comments
Better for is to use HttpHandler. It allows you to output anything you want. Alternative way is to use web method, but I'm not sure that its going to be easy to return json, not XML
