什么是回发? [英] What is a postback?

查看:150
本文介绍了什么是回发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到了一个回发的最好的解释是从维基。

The best explanation I've found for a postBack is from Wiki.

回发是一个HTTP POST到该形式是在同一页上。

虽然本文不讲解如何需要ASP第二个页面,但ASP.NET不再需要,它并没有提供多少细节和背景。我在找上回发信息的刻着'大部头。很像的简单的问题:我怎么能清洁屋可以通过此 900页的书地址。我不需要900页的身价,但具体细节请。我找到了ASP.NET生命周期中一个漂亮的小教程,但它严重地掩盖了回发(除其他事项外)。

While the article does explain how a second page was needed in ASP, but no longer needed in ASP.NET, it doesn't give much detail or background. I am looking for a freakin' tome of information on PostBacks. Much like the simple question of "how can I clean a house" can be address by this 900 page book. I don't need 900 pages worth, but details please. I found a nice little tutorial for ASP.NET life cycle, but it seriously glosses over postbacks (amongst other things).

我期待开发商的谁一直围绕前.NET和真正理所当然不采取这些事情。书籍和超链接是合理的答案,或增加对你的答案。

I am looking to the developer's who have been around before .NET and really don't take these kinds of things for granted. Books and hyperlinks are reasonable answers or addition's to your answer.

推荐答案

到目前为止,我已经看到了正确的答案提到多次,而且几乎每个人都来了害羞的我认为主观上是标志。

So far I've seen the right answer alluded to repeatedly, and almost everyone has come shy of what I consider subjectively to be the mark.

让我们从基础开始:

这是HTTP请求可以是任何 HTTP动词中的,但主要的两个人使用是GET和POST 。哦,那是两个程序员使用最频繁。其他人都具有一定的目的,如果他们在服务器上实现。当您发送信息到服务器,你可以这样做既可以通过使用的URL(请求页)或请求的主体内(POST,PUT,DELETE,例如)。

An HTTP request can be any of the HTTP verbs, but the primary two people use are GET and POST. Well, those are the two a programmer uses most frequently. The others all have some purpose, if they're implemented on the server. When you send information to the server, you can do so either through the use of the URL (to request a page) or within the body of the request (POST, PUT, DELETE, for instance).

现在你问(我相信),在一个GET请求的URL通常包含的数据,这是事实,但根据W3C,你不应该使用GET改变状态,但我们经常这样做。这有点黑客攻击,我们都同意是实际使用,而不是黑客。这是否使我离开了你一个黑客或实际实现细节。

Now you'll remark (I'm sure) that the URL in a GET request often contains data, and this is true, but according to W3C, you should not use GET to alter state, and yet we do often. It's sort of a hack that we all agree is an actual use, and not a hack. Whether that makes it a hack or an actual implementation detail I leave up to you.

所以,当你发送POST体与表单元素,你发回的某些元素(跳过别人现在,你可以从这里看着办吧)。这些元素如何被定义是由你和你的工作环境中,你的可能的帖子在体内一个JSON元素的服务器,或者使用XML,或表单域。一般来说,我们做从表单元素的帖子在HTML的

So when you send the body of the POST (skipping the others for now, you can figure it out from here) with the form elements, you're sending back certain elements. How those elements are defined is up to you and to the environment you're working in. You could post to a server with a JSON element in the body, or with XML, or with form fields. Generally we do posts from a FORM element in the body of the HTML.

现在大家都说,哦,回发是一个网页后续请求。但是,事实并非如此。回发是当你通过POST发送数据 - >回服务器。我这样说是因为一个GET请求和POST请求的区别是,如果数据包括在体内(和所用的动词,但是客户通常都知道如何对付这一点)。你的回发到在第一时间的页面的页面被访问,而事实上ASP.NET有这样做,在库中的工具。你当然可以有一个桌面客户端POST数据到服务器(想想微博)没有表现出任何网页都从服务器(好吧,所以微博可能不是用在这里的例子最好的概念,但我想说明你可以使用的客户端不显示网页,因此没有要求是必要的)。

Now everyone says, "oh, a postback is a subsequent request to a page." But, that's not true. A postback is when you send data via POST -> back to the server. I say this because the difference between a GET request and a POST request is if data is included in the body (and the verb used, but the client usually knows how to deal with that). You could postback to the page on the first time the page is visited, and in fact ASP.NET has tools for doing that in the library. You could certainly have a desktop client POST data to a server (think Twitter) without showing any webpage at all from the server (ok, so twitter is probably not the best concept to use for an example here, but I want to illustrate that you can use a client that doesn't show the webpage, so no request is necessary).

所以真的,你应该在回传读什么就有什么我张贴数据传回服务器进行处理。这是您最初检索到的页面用GET来显示用户的&LT presumed;形式> 有元素<输入> 字段他们互动,并在年底你将数据发送回。但我希望你能看到,它并不一定是按照这个顺序。

So really what you should read there in "postback" is "I'm POSTing data BACK to the server for processing". It's presumed that you retrieved the page initially with a GET to show the user the <form> element that has <input> fields for them to interact with, and that at the end you're sending data back. But I hope you can see that it doesn't have to be in that order.

因此​​,这里是别的东西来考虑:

So here's something else to consider:

如果你给用户一个页面一堆&LT的;输入&GT; 和没有&LT;形式&GT; 而是,有一个按钮,在JavaScript连接到Concat的所有&LT;输入&GT; s的&安培;价值-N = ,并将它们发送一个GET?做同样的事情,但只是违反使用GET的请求的这一概念。 <罢工>(可能)随后的讨论中鼓励我强化了GET应该没有副作用(没有更新的值)

What if you gave the user a page with a bunch of <input>s and no <form> but instead, had a button wired up in javascript to concat all those <input>s with &value-n= and send them as a GET? Does the same thing, but violates that concept of only using GET for requests. (possibly) ensuing discussion encourages me to reinforce that GET should have no side effects (no updating values)

这是怎么来的,你可以派人链接到谷歌的搜索,例如。所以,我们并不总是要回发到服务器以获取数据。

It's how come you can send someone a link to a google search, for instance. So we don't ALWAYS have to POST BACK to the server to get data.

希望这有助于。
干杯

Hope this helps. Cheers

这篇关于什么是回发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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