ASP.NET页面的方法VS Web服务 [英] ASP.NET page methods vs web service

查看:142
本文介绍了ASP.NET页面的方法VS Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个动态的部分负荷asp.net页面,我想用jQuery来调用页面方法或Web服务来获取内容的HTML。

I am building a dynamic partial load asp.net page, I would like to use jQuery to call page methods or web service to retrieve the content HTML.

页方法或Web服务,性能明智的,哪种方式更好呢?

page methods or web service, performance wise, which way is better?

如果我打电话页方法,在服务器端,并在页面经过完整的生命周期?

If I call page method, on the server side, does the page go through full lifecycle?

有没有什么好的资源,帮助我更好地理解网页的方法?

Is there any good resources help me to better understand page method?

推荐答案

您可以拨打PageMethods和Web服务而无需的ScriptManager 控制(生成JavaScript代理对象允许您使用熟悉的语法来调用Web服务和页面方法)。

You can call PageMethods and Web Services without needing a ScriptManager control (which generates the JavaScript proxy objects that allow you to use familiar syntax to call web services and page methods).

文章使用jQuery直接调用ASP .NET AJAX页面的方法

文章使用jQuery来消费ASP.NET的JSON Web服务

下面是从2007年的Web服务和页面方法的 MSDN文章。通过它简单地看,这似乎仍然是相关的,他们是如何工作的/你需要做的就是他们今天的工作。

Here's an MSDN article from 2007 on Web Services and Page Methods. Looking briefly through it, it seems to still be relevant to how they work / what you need to do to get them to work today.

性能方面:

您可能希望页面的方法来提供   比Web服务更好的性能。   毕竟,解决Web服务   电话,ASP.NET运行时有   解析SOAP数据包。然而,这   是不完全正确的。 ASP.NET AJAX   安装特制的HTTP处理程序   (见图3),它可以拦截所有   ASMX请求。请用/ JS   后缀的处理方式不同,   直接用JSON有效载荷工作   和Web服务方法。结果是,   没有肥皂参与任何与   请求的身体根本包含   输入参数的JSON流。   对于非AJAX请求,新HTTP   处理器仅委派回拨   到原来的ASP.NET处理程序   了解SOAP。

You might expect page methods to offer better performance than Web services. After all, to resolve Web service calls, the ASP.NET runtime has to parse SOAP packets. This, however, isn't exactly true. ASP.NET AJAX installs a tailor-made HTTP handler (see Figure 3) that intercepts all ASMX requests. Requests with a /js suffix are processed differently, working directly with the JSON payload and Web service method. As a result, no SOAP is involved whatsoever and the body of the request simply contains the JSON stream of input arguments. For non-AJAX requests, the new HTTP handler just delegates the call back to the original ASP.NET handler that understands SOAP.

在响应页面的生命周期,页面方法做的不可以通过服务器端页面生命周期(还有一个的客户端页面生命周期太)。

In response to the Page Lifecycle, Page Methods do not go through the server-side Page LifeCycle (there is also a client-side Page Lifecycle too).

这篇关于ASP.NET页面的方法VS Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆