Understanding ASP .NET Page Life Cycle and top interview questions related to it
ASP .NET is an open-source server-side web application framework designed for web development. ASP .NET programming is used for creating dynamic and much secure websites. It is also used for creating templates, database management, frameworks, database access, and other activities. ASP.Net development or programming has a huge scope in helping you create web applications and solutions. It offers crystal reporting 2008 services. Offering a wide use in the development of business to business (B2B) and business to customer (B2C) application development has become a developers preferred choice.
To be a professional ASP .NET developer one must know the most important features of its library and core functionalities. One of the core features includes ASP .NET Page Life Cycle. In this discussion, we will learn the basics of ASP .NET Page Life Cycle and then we will focus on the most important questions about Page Life Cycle which you are likely to face in the interview for a job in ASP .NET.
What is ASP .NET Page Life Cycle: In ASP .NET a particular web page has to go through some phases to execute properly. When a page runs, the page goes through a life cycle in which it performs a series of processing steps. These steps are called the ASP .NET Page Life Cycle. It is very important for every developer to learn about the ASP .NET Page Life Cycle as it gives you the understanding of the whole architecture based on which an ASP .NET page runs.
These are the basic steps of ASP .NET Page Life Cycle:
- Page Request: It occurs before the life cycle begins. When a page is requested from the server, ASP .NET checks if it is requested for the first time. If it is, then it parses and compiles the page.
- Page Start: In this stage, two objects are created, named as Request and Response. The Request object holds the information when it is requested and the Response objects hold the information which is to be sent back to the user.
- Initialization: In this stage, all the controls are initialized on a web page. Here each control's UniqueID property is set and master page is applied to the page.
- Page Load: In this stage, the page is loaded with all the default values. The control properties are loaded with information.
- Postback event handling: In this stage, the event handler is called if the page request is postback. After that, the Validate method of all validator controls is called.
- Rendering: Before rendering, the view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream object of the page's Response property.
- Unload: At this stage, the requested page has been fully rendered and is ready to terminate.at this stage all properties are unloaded and cleanup is performed.
Related interview questions about ASP .NET and ASP .NET Page Life Cycle: Here you will learn about some of the most asked interview questions about ASP .NET and ASP .NET Page Life Cycle in ASP .NET while you are going to set for a job or real-life interview.
1)Question: What is ASP.NET MVC?
Answer: ASP.NET MVC is a web application Framework. It is light-weight and highly testable Framework. MVC separates the application into three components Model, View, and Controller.
2)Question: In which event of the page cycle is the ViewState available?
Answer: After the Init() and before the Page_Load().
3)Question: List the events in the page life cycle.
4)Question: Explain Model, Controller and View in MVC.
Model: A business entity and it is used to represent the application data.
Controller: Request sent by the user always scatters through controller and responsibility is to redirect to the specific view using View() method.
View: The presentation layer of MVC.
5)Question: What's the use of Response.Output.Write()?
Answer: We can write formatted output using Response.Output.Write().
6)Question: From which base class all Web Forms are inherited?
Answer: Page Class.
7)Question: What are the different validators in ASP.NET?
- Required field Validator
- Range Validator
- Compare Validator
- Custom Validator
- Regular expression Validator
- Summary Validator
8)Question: Which validator control you use if you need to make sure the values in two different controls matched?
Answer: Compare Validator control.
9)Question: What are the different Session state management options available in ASP.NET?
Answer: In-Process and Out-of-Process.
10)Question: What is caching?
Answer: Caching is a technique used to increase performance by keeping frequently accessed data or files in memory. The request for a cached file/data will be accessed from cache instead of the actual location of that file.
11)Question: What are the different types of caching?
Answer: ASP.NET has 3 kinds of caching :
- Output Caching
- Fragment Caching
- Data Caching.
12)Question: Types of caching in ASP .NET
- Page Caching
- Fragment Caching
- Data Caching
These are some of the questions that are frequently asked in the interview with ASP .NET. We hope you found this information helpful. If you want to learn ASP .NET from the beginning then these are the Best ASP .NET Books to Learn MVC 5.