Explain the ASP.NET page life cycle in brief.

ASP.NET goes through a series of stages in the life cycle of each page.

  • Page request. The user requests a page. ASP.NET decides whether to compile it or serve it from a cache.
  • Page Start. The Request and Response objects are created.
  • Page Initialization. All page controls are initialized, and any themes are applied.
  • Page Load. ASP.NET uses the view state and control state properties to set the control properties. Default values are set in the controls.
  • Postback event handling. This event is triggered if the same page is loaded again.
  • Rendering. ASP.NET saves the view state for the page and writes the output of rendering to the output stream. It happens just before the complete web page is sent to the user.
  • Unload. The rendered page gets sent to the client. ASP.NET unloads page properties and performs cleanup. All unwanted objects are removed from memory.