post back

https://docs.microsoft.com/zh-cn/dotnet/api/system.web.ui.page.ispostback?view=netframework-4.7

https://docs.microsoft.com/zh-cn/dotnet/api/system.web.ui.usercontrol.ispostback?view=netframework-4.7.1

Understanding The Complete Story of Postback in ASP.NET

https://www.codeproject.com/Articles/811684/Understanding-The-Complete-Story-of-Postback-in-AS

Introduction

In the old HTML, the only way to make something updated on the webpage is to resend a new webpage to the client browser. That's what ASP used to do, you have to do this thing call a "PostBack" to send an updated page to the client.

In ASP .NET, you don't have to resend the entire webpage. You can now use AJAX, or other ASP.NET controls such that you don't have to resend the entire webpage.

If you visit some old website, you would notice that once you click something, the entire page has to be refresh, this is the old ASP. In most of the modern website, you will notice your browser doesn't have to refresh the entire page, it only updates the part of the content that needs to be updated. For example, in Stackoverflow, you see the page update only the content, not the entire webpage.

Programming model in old ASP for using POST method in form is to post the values of a Form to a second page. The second asp page will receive the data and process it for doing any validation or processing on the server side.

With ASP .Net, the whole model has changed. Each of the asp .net pages will be a separate entity with ability to process its own posted data. That is, the values of the Form are posted to the same page and the very same page can process the data. This model is called post back.

Each Asp .net page when loaded goes through a regular creation and destruction cycle like Initialization, Page load etc., in the beginning and unload while closing it. This Postback is a read only property with each Asp .Net Page (System.Web.UI.Page) class. This is false when the first time the page is loaded and is true when the page is submitted and processed. This enables users to write the code depending on if the PostBack is true or false (with the use of the function Page.IsPostBack()).

 

 What is PostBack in ASP.NET

http://www.c-sharpcorner.com/uploadfile/2f73dd/what-is-postback-in-Asp-Net/

To work with the ASP.Net Web Controls events, we need a solid understanding of the web page life cycle. The following actions will be taken place when a user changes a control that has the AutoPostBack property set to true :

  1. On the client side, the JavaScript _doPostBack function is invoked, and the page is resubmitted to the server.
  2. ASP.NET re-creates the Page object using the .aspx file.
  3. ASP.NET retrieves state information from the hidden view state field and updates the controls accordingly.
  4. The Page.Load event is fired.
  5. The appropriate change event is fired for the control. (If more than one control has been changed, the order of change events is undetermined.)
  6. The Page.PreRender event fires, and the page is rendered (transformed from a set of objects to an HTML page).
  7. Finally, the Page.Unload event is fired.
  8. The new page is sent to the client.

To watch these events in action, we can create a simple event tracker application. 

 

What is a postback?

https://stackoverflow.com/questions/183254/what-is-a-postback

The following is aimed at beginners to ASP.Net...

When does it happen?

A postback originates from the client browser. Usually one of the controls on the page will be manipulated by the user (a button clicked or dropdown changed, etc), and this control will initiate a postback. The state of this control, plus all other controls on the page,(known as the View State) is Posted Back to the web server.

What happens?

Most commonly the postback causes the web server to create an instance of the code behind class of the page that initiated the postback. This page object is then executed within the normal page lifecycle with a slight difference (see below). If you do not redirect the user specifically to another page somewhere during the page lifecycle, the final result of the postback will be the same page displayed to the user again, and then another postback could happen, and so on.

Why does it happen?

The web application is running on the web server. In order to process the user’s response, cause the application state to change, or move to a different page, you need to get some code to execute on the web server. The only way to achieve this is to collect up all the information that the user is currently working on and send it all back to the server.

Some things for a beginner to note are...

  • The state of the controls on the posting back page are available within the context. This will allow you to manipulate the page controls or redirect to another page based on the information there.
  • Controls on a web form have events, and therefore event handlers, just like any other controls. The initialisation part of the page lifecycle will execute before the event handler of the control that caused the post back. Therefore the code in the page’s Init and Load event handler will execute before the code in the event handler for the button that the user clicked.
  • The value of the “Page.IsPostBack” property will be set to “true” when the page is executing after a postback, and “false” otherwise.
  • Technologies like Ajax and MVC have changed the way postbacks work.

 

 

https://stackoverflow.com/questions/4251157/what-is-a-postback

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.

Let's start with the basics:

An HTTP request can be any of the HTTP verbs, but the primary two used by  people 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).

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.

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.

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).

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:

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

 

 

 

 

The PostMessage function is used to post a message to the message queue of a thread. This function is one of the ways to communicate between different threads in Windows. To hook the PostMessage function, you can use the Detours library provided by Microsoft. Detours allows you to intercept function calls and redirect them to your own function. Here's an example of how to hook the PostMessage function using Detours: ```c++ #include <windows.h> #include <detours.h> // Define a function pointer for the original PostMessage function typedef BOOL (WINAPI *POSTMESSAGE)(HWND, UINT, WPARAM, LPARAM); // Define a global variable to hold the address of the original PostMessage function POSTMESSAGE g_pOrigPostMessage = NULL; // Define your own PostMessage function BOOL WINAPI MyPostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { // Do something before calling the original PostMessage function // ... // Call the original PostMessage function BOOL bRet = g_pOrigPostMessage(hWnd, Msg, wParam, lParam); // Do something after calling the original PostMessage function // ... return bRet; } // Hook the PostMessage function BOOL HookPostMessage() { // Get the address of the original PostMessage function HMODULE hUser32 = GetModuleHandle("user32.dll"); g_pOrigPostMessage = (POSTMESSAGE)GetProcAddress(hUser32, "PostMessageA"); // Detour the PostMessage function to your own function if (DetourTransactionBegin() == NO_ERROR) { if (DetourUpdateThread(GetCurrentThread()) == NO_ERROR) { if (DetourAttach(&(PVOID&)g_pOrigPostMessage, MyPostMessage) == NO_ERROR) { if (DetourTransactionCommit() == NO_ERROR) { return TRUE; } } } } return FALSE; } // Unhook the PostMessage function BOOL UnhookPostMessage() { // Detour the PostMessage function back to the original function if (DetourTransactionBegin() == NO_ERROR) { if (DetourUpdateThread(GetCurrentThread()) == NO_ERROR) { if (DetourDetach(&(PVOID&)g_pOrigPostMessage, MyPostMessage) == NO_ERROR) { if (DetourTransactionCommit() == NO_ERROR) { return TRUE; } } } } return FALSE; } // Example usage int main() { // Hook the PostMessage function if (HookPostMessage()) { // Call the PostMessage function PostMessage(NULL, WM_USER, 0, 0); // Unhook the PostMessage function UnhookPostMessage(); } return 0; } ``` Note that the Detours library is not officially supported by Microsoft and is intended for research and experimentation purposes only. Use it at your own risk.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值