在您看来,用ASP.NET创建纯Javascript应用程序的服务器端最好的方法是什么?
WCF渲染JSON?IHttpHandler?
更新
与GMail类似,它在浏览器中运行(包含大量Javascript),并使用Ajax提交和接收数据。
发布于 2010-12-02 16:22:08
在经典的ASP.NET中,很容易使用处理程序(IHttpHandler):
context.Response.ContentType = "application/json"
context.Response.Clear()
context.Response.AddHeader("Pragma", "no-cache")
context.Response.AddHeader("Expires", "-1")
context.Response.Write(myJsonString)在标记中,使用以下jQuery代码:
$.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'); }
});发布于 2010-12-02 16:09:11
是的,我想说是WCF服务返回JSON。另一个选项,尽管不那么直观,将是使用ASP.NET MVC并返回JSON。
在您的更新问题之后,我将真正地推荐ASP.NET MVC --它将允许您拥有大量的灵活性,并提供您所要求的内容。
https://stackoverflow.com/questions/4337049
复制相似问题