什么是部分回发?

发布于 2024-07-29 20:18:31 字数 342 浏览 3 评论 0原文

我是一位经验丰富的 Web 开发人员,涉足多个不同的 Web 技术堆栈。 我目前在 .Net 工作,我对部分回发感到好奇。

我了解部分回发的功能是什么以及如何以编程方式使用它,但我不喜欢使用我不理解的技术,部分回发是如何实现的。

我了解 HTTP 请求和异步请求,但让我对部分回发感到困扰的是,它似乎两者兼而有之。

也许我只是错过了一些东西,但在我看来,部分请求同时执行了这两件事,首先触发异步 POST 请求,但浏览器似乎意识到了,并且活动指示器开始旋转,这通常只发生在 HTTP 请求页面期间使成为。

那么谁能解释一下 Microsoft 如何在 HTTP 请求级别实现部分回发呢?

I'm an experienced web developer in several different web technology stacks. I currently work in .Net and I've become curious about the Partial Postback.

I understand what the Partial Postback's function is and how to work with it programatically, but I don't like using technology that I don't understand, how is a Partial Postback implemented.

I understand HTTP Requests and Asynchronous Requests, the thing that bugs me about the Partial Postback is that it seems to be both.

Maybe I'm just missing something but it appears to me that the Partial Request does both, first firing off an Asynchronous POST Request but the Browser seems to be aware and the activity indicator starts to spin, which normally only occurs during an HTTP Request Page Render.

So can anyone shed some light on how Microsoft implemented, at the HTTP Request level, the Partial Postback?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

葬﹪忆之殇 2024-08-05 20:18:31

来自如何在 ASP.NET 2.0 中编写自己的部分回发

部分回发构造的核心是 XMLHttpRequest,一个 DOM API。 它可以在 Web 浏览器脚本语言(例如 JavaScript)中使用,将 HTTP 请求直接发送到 Web 服务器,而无需重新加载整个页面并在脚本语言中再次处理来自服务器的响应。 然后,可以使用 XML 形式的该数据来操作客户端的页面元素。

单击 ASPX 页面上的按钮后,将使用 XMLHttpRequest API 发出客户端 HTTP 请求。 该请求由 Web 服务器上的 HttpHandler 处理。 HttpHandler 接收请求,处理它,并将响应发送回 ASPX 页面上的 XMLHttp 对象。 XMLHttp 对象依次使用响应并呈现适当的 UI 更改,而浏览器无需完全刷新页面。

UpdatePanel 不仅刷新其包含的控件,还在处理后用从服务器获取的值更新 ViewState 值。

From How to write your own partial postback in ASP.NET 2.0:

At the heart of the partial post back construction is the XMLHttpRequest, a DOM API. It can be used inside a web browser scripting language, such as JavaScript, to send an HTTP request directly to a web server without having to reload the entire page and handling the response from the server again within the scripting language. This data, in the form of XML, can then be used to manipulate the page elements on the client side.

When the button on the ASPX page has been clicked, a client side HTTP request is made using the XMLHttpRequest API. This request is handled by an HttpHandler on the web server. The HttpHandler receives the request, processes it, and sends back the response to the XMLHttp object on the ASPX page. The XMLHttp object in turn consumes the response and renders the appropriate UI changes without the browser having to do a full refresh of the page.

An UpdatePanel not only refreshes the controls which it contains, it also updates the ViewState value with the one obtained from the server, after processing.

趁微风不噪 2024-08-05 20:18:31

我知道这个问题已经得到解答,但我不同意这个答案...

以我的拙见,上述文章中滥用了术语“部分回发”“如何在 ASP.NET 2.0 中编写自己的部分回发”。 在本文中,作者向您展示了如何对 HttpHandler 进行 AJAX 调用。 这是一个与在 ASP.NET 中进行 PartialPostback 调用非常不同的过程。

我相信(上述答案)事后评论中回避了这种“差异”,其中指出:

An UpdatePanel不仅刷新它包含的控件,它还在处理后用从服务器获取的值更新 ViewState 值。

虽然最后的注释有点难以捉摸地说明了使用 ASP 的“部分回发”的定义.NET UpdatePanel...它没有解释什么是部分回发(这又是一个与普通 AJAX 调用非常不同的过程)。

详细说明...


使用 UpdatePanel 的 MICROSOFT ASP.NET AJAX:
在基本层面上,Microsoft AJAX 通过部分页面回发支持异步请求。 部分回发与同步全页回发一样迭代相同的页面生命周期,但仅刷新页面上的特定区域或控件 - 从而实现部分页面呈现。 MICROSOFT ASP.NET AJAX 依赖于拦截器模式来生成和处理部分回发。 初始化时,MICROSOFT ASP.NET AJAX JavaScript 库添加一组客户端事件处理程序来拦截通常会启动整页回发的调用。 处理函数拦截来自已注册控件的回发调用,生成部分回发,处理响应内容,然后异步更新页面内容。 由于 MICROSOFT ASP.NET AJAX 是基于现有 ASP.NET 回发架构构建的,因此它利用事件验证并在整个部分回发过程中维护视图状态。 标准的“正常”AJAX 调用不会执行这些操作!

简而言之...

MICROSOFT ASP.NET AJAX 使用“正常”AJAX 来“ajax-ify” ' 它是页面并实现部分更新......这样做时,它会进行交易 & 在一次调用中多次管理视图状态。 这就是为什么它被称为“部分回发”。 随后,这也是为什么他们最初将 UpdatePanel 描述为使页面“ajaxy”的一种方法(因为它与使用 AJAX 不同)。


普通 AJAX 调用:
在浏览器中使用 JavaScript 发起的异步请求会创建与服务器的新连接。 是的...这可能包括对页面的有状态回发,但也包括对当前页面之外的资源的无状态请求。 但是,在异步回发的情况下,只有服务器上当前页面需要处理的信息会被传递到请求中(并且您可以控制这一点)。意思是,整个页面不需要提交,不需要管理视图状态 嵌入到页面生命周期中的(本机)开销可以被绕过。 同时,异步回发仅调用与处理当前请求相关的服务器事件。 这就是为什么普通 AJAX 比部分回发快得多!

这些要点说明...

不仅什么是“部分回发”...而且为什么有“部分回发”和“ajax”调用之间的区别。 这就是为什么这是一个更好的答案。

I know this question has already been answered, but I disagree with the answer...

In my humble opinion, the term 'partial postback' is being misused in the above-mentioned article "How to write your own partial postback in ASP.NET 2.0". In this article, the author shows you how to make an AJAX call to an HttpHandler. This is a very different process than making PartialPostback calls in ASP.NET.

I beleive this 'difference' is eluded to in the (above answers) after-thought comment which states:

"An UpdatePanel not only refreshes the controls which it contains, it also updates the ViewState value with the one obtained from the server, after processing."

While this final comment somewhat elusively-illustrates the definition of a 'Partial Postback' using an ASP.NET UpdatePanel...it doesn't explain what a partial-postback is (which, once again, is a very different process than that of a normal AJAX call).

To elaborate...


MICROSOFT ASP.NET AJAX Using UpdatePanel's:
At a basic level, Microsoft AJAX supports asynchronous requests via a partial-page-postback. Partial postbacks iterate through the same page lifecycle as a synchronous full page postback, but only specific regions or controls on the page are refreshed - thus achieving partial page rendering. MICROSOFT ASP.NET AJAX is dependent on the interceptor pattern to generate and handle a partial-postback. Upon initialization, MICROSOFT ASP.NET AJAX JavaScript libraries add a set of client event handlers to intercept calls that would normally initiate a full page postback. The handler functions intercept postback calls from registered controls, generate a partial postback, process the response content and then update page content asynchronously. Since MICROSOFT ASP.NET AJAX is built on the existing ASP.NET postback architecture it utilizes event-validation and maintains the view state throughout the partial-postback process. Your standard 'normal' AJAX call doesn't do these things!

To put it shortly...

MICROSOFT ASP.NET AJAX uses 'normal' AJAX to 'ajax-ify' it's pages and achieve partial-updates...and in doing so, it trades & manages view-state MULTIPLE times throughout a single call. This is WHY it is called a 'partial-postback'. Subsequently, this is also why they originally described the UpdatePanel as a means to make your pages 'ajaxy' (because it is not the same thing as using AJAX).


NORMAL AJAX Calls:
Asynchronous requests initiated using JavaScript in the browser creates a new connection to a server. Yes...this may include stateful postbacks to a page, but also stateless requests to resources apart from the current page. However, in the case of an asynchronous postback , only the information that needs to be processed by the current page on the server is passed INTO the request (and you can control this). Meaning, the contents of the entire page do not need to be submitted, no view-state needs to be managed & the (native) overhead embedded into the page-lifecycle can be bypassed. Meanwhile, an asynchronous postback only calls server-events associated with processing the CURRENT REQUEST. This is why normal AJAX is so much faster than PARTIAL POSTBACKS!

These Points Illustrate...

Not only WHAT a 'partial postback' is...but WHY there is a difference between a 'partial postback' and an 'ajax' call. Which is why this is a better answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文