Making a simple page that returns JSON-formatted data using ASP .net
<p>I am new to ASP. I want to make an ASP page that would return on request JSON formatted data. I followed a few tutorials and all i can see now is the link of a full fledged page with callbacks in my code. So in essence the server is ouptputting a lot of HTML which obviously is not valid JSON. So my only question is how do I go about making such a web page. I want my application to be designed such that when I go to a web page, say <code>http://localhost:8080</code> (or something similar), a callback or a function in my C# code connects to the database, gathers some info and sends it back as the Response in valid JSON. I'm not looking for libraries which can achieve the same effect, but something like how do I achieve it by simply using a set of <code>Response.Write</code> statements.</p>

<p>Please pardon me if I may give the idea that I am not coherent with my concepts, because I'm really new to this entire thing.</p>

<p>Any help is greatly appreciated.</p>

<p>Regards,
p1n3appl3</p>

<p>EDIT: I'm currently using the following JavaScript code:</p>

<pre><code>var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:47949/Default.aspx/NameChange");
xhr.onreadystatechange = function () {
    if (xhr.readyState == 4 &amp;&amp; xhr.status == 200) {
        alert(xhr.responseText);
    }
}

xhr.send("");
</code></pre>

<p>It makes the call and all, everything's fine but the problem is that it returns the entire code of the "Default.aspx" page again. I mean, the method <code>NameChange</code> isn't even called (I've tested this by setting breakpoints).</p>

<p>What am I doing wrong?</p>
