In your opinion, what's the best way to create the server side to a pu开发者_StackOverflow中文版re 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.
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'); }
});
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.
精彩评论