javascript - 哪个更适合 jQuery.ajax 调用? .Net Web 服务还是 .ashx?

标签 javascript asp.net web-services jquery ashx

我最近一直在练习 jQuery.ajax()。我已经开始学习调用 .Net 网络服务 qith jQuery.ajax()。

现在我正在考虑是否要 jQuery.ajax() 调用服务器上的某些服务方法;使用 .Net Web 服务是否仍然有意义,或者我应该改用 .ashx 处理程序?

谢谢!

最佳答案

来自 the ASP.NET forums 的两句话:

Unless it's an extremely high load situation, you'll find that all three perform nearly identically. The performance of your code inside the handler/service is going to be the limiting factor.

For simple AJAX calls that are only intended to be exposed to the browser, I don't think WCF justifies its added complexity. It's great for some things, but I have a hard time recommending it for this.

Between ASMX and HttpHandler, I go with ASMX every time. An HttpHandler is probably negligibly faster, but an ASMX "ScriptService" makes JSON serialization and deserialization of complex types transparent, which is immensely useful.


Here's another option:

If you have some methods you want to run (and you like JQuery)... I suggest looking at this:

http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/

and related articles. Works beautiful. Very efficient as far as bandwith goes. They also have an article on querying .asmx services.

There is no messing around with the bloated size of ASP.NET's innate AJAX. Since AJAX out of the box can be very bloated. Plus it's very easy.

关于javascript - 哪个更适合 jQuery.ajax 调用? .Net Web 服务还是 .ashx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5543069/

相关文章:

java - 出现错误 找不到 Java 类 java.util.ArrayList/List<java.lang.String> 的消息正文编写器

java - SOAP 网络服务客户端的工具,可以获取凭据并提供输入

javascript - 如何删除子节点并在javascript中保留其子节点?

javascript - 为什么每个人都将端口存储为快速变量?

c# - StructureMap 和 HTTP 请求范围的服务 - 为什么我的服务在一个范围内创建了两次?

asp.net - 从任意 URL 获取值

c# - 获取 "Could not create SSL/TLS secure channel"

javascript - 使用 jQuery 将 'script' 放在 BODY 标记的末尾之前

javascript - Backbone.js - Coffeescript 扩展

asp.net - AppCache 适用于 Firefox (30) 但不适用于 IE (11)