1

In your opinion, what's the best way to create the server side to a pure Javascript application with ASP.NET?

WCF rendering JSON? IHttpHandler?

Update

Like GMail, that runs in the browser (with a lot of Javascript) and submit and receive data with Ajax, for example.

3
  • 2
    If it's a pure javascript application, why do you need ASP.NET or any server side tech? Commented Dec 2, 2010 at 16:08
  • 1
    Node.js - The best way to write server side JavaScript in any language and/or framework. Commented Dec 2, 2010 at 16:09
  • Updated to explain what is "pure javascript application". Commented Dec 2, 2010 at 16:25

2 Answers 2

2

In classic ASP.NET, it's fairly easy to use handlers (IHttpHandler):

context.Response.ContentType = "application/json"
context.Response.Clear()
context.Response.AddHeader("Pragma", "no-cache")
context.Response.AddHeader("Expires", "-1")
context.Response.Write(myJsonString)

In your markup, use the following jQuery code:

$.ajax({
    type: "GET",
    url: "GetTasksForTaskSet.ashx?tasksetid=" + guid,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data) {
        for(var i = 0; i < data.length; i++) {
            // do something
        },
    error: function(){ alert('error'); }
});
Sign up to request clarification or add additional context in comments.

Comments

1

Yeah, I'd say a WCF service returning JSON. Another option, though less intuitive, would be to use ASP.NET MVC and return JSON.

After your updated question, I would really recommend ASP.NET MVC it will allow you to have a ton of flexibility, and provide exactly what your asking for.

2 Comments

I would argue that ASP.NET MVC for JSON is much more intuitive than WCF :)
After the update, yes that would make much more sense; at first I was thinking the OP wanted to simply create a Web Service style back-end for his app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.