Before going to ASP.NET Interview Questions and Answers, the very first thing one must remember who is attending for .NET Interview is don’t go by book definition. Secondly, I suggest everyone, understand the concept with a practical example. The third and most important thing to remember, keep a good knowledge of your projects mentioned on the resume.
ASP.NET Interview Questions
In this article asp.net interview questions, we concentrate on the FAQs asked in top MNCs. Let’s try to understand the concept of each topic and if required with an example for better understanding.
Q1: What is ASP.NET?
ASP.NET is a framework developed by Microsoft, the successor of ASP(Active server pages). Using ASP.NET framework, we can develop the new generation of websites or web applications. In other words, the ASP.NET framework allows you to create, execute and deploy the web application and web services.
Advantages of using ASP.NET
- Separation of code from HTML page conviction helps the developers to work seamlessly on core business logic implementation and design independently.
- State Management solves the problems of managing the state of the webpage using the concepts of sessions state management and application state management.
- The graphical user interface makes the developer easy by making use of drag-drop control from the toolbox and also IntelliSense support provided. IntelliSense support provided not only for server-side controls even for HTML and XML.
- Ability to update files while the server is up and running and when clients are connected. By making use of the framework features, the new files are served on the subsequent client requests seamlessly.
- As ASP.NET build under server-side technology, helps every developer to develop the most robust and secure web applications.
Q2: Explain about ASP.NET Page Lifecycle?
When a client requests a page, then the page response(served) sent to the client and displayed. In the phase of request and response, there are a lot of exciting stages involved. These exciting phases are what we call it as asp.net page lifecycle.
There are four crucial phases involved in the asp.net phase life cycle, which every developer should remember
- Initialisation: During this phase, initialization of all the controls on the web page is performed. Each control is set with a UniqueID property so that it can be utilized at runtime by the programmer. The Page_Init event is called only once when the first request is made.
- Loading: The Page_Load event is used to know, whether page loaded for the first time or not.
- Rendering: During Page_Prerender phase options like ViewState is stored and custom themes can be fixed.
- Unloading: The Page_Unload is the last phase, where all controls are ready to render to the client.
Q3: What is ViewState?
Every webpage is stateless by default If ViewState technique is not there. Next question comes what is Stateless? Default, any HTML page cannot preserve the values after a postback, so this is why we call webpage as stateless. The only solution to overcome this is the ViewState.
The process of preserving the page control properties like ID, text, tooltip, etc. after a postback is known as maintaining the state of the webpage. The ASP.NET page framework uses the concept of ViewState to store control settings between postbacks.
Q4: What is the Web.config file in ASP.NET?
The web.config file is one of the most critical file in development of the ASP.NET application. In simple terms, the web.config is an XML file which is separated from your application code so that it does not impact the development code files.
The configuration file enables the web application settings for compiler options, user authentication, debugging, connection strings, and more. Please find the few critical “web.config” settings mentioned with examples.
- Compiler and debugger settings: To serve the request of any web application, ASP.NET must compile. In compilation tag, debug, targetFramework are two important settings.
- debug: true/false.
- targetFramework: 3.0/3.5/4.0 etc.
- Connection strings: Specifies the collection of database connection settings.
uid=<user name>;pwd=<secure password>" />
- Custom Errors: Enables the application to handle the unexpected error, like showing the custom error pages.
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
Q5: What are the data controls available in ASP.NET
The controls are having the data source property signify as data controls in ASP.NET. The data source property is a dominant feature which allows the application to bind data from the data table, arrays, collections. It acts as a wrapper between controls and database, while read and write operations. The data binding uses a special syntax [<%# %] to evaluate the expression.
List of data-bind controls in ASP.NET
- much more.
Q6: What is User control in ASP.NET?
User controls in ASP.NET are much like derived/composite controls which works much like an ASP.NET web page. You can add existing web controls as per customer requirement and markup to user control. Moreover, you can define with custom properties and methods. The user control you can embed them in any web page, where they act like as a unit and gets your task done, just like your asp.net web controls.
Q7: What are the different Session state management techniques available in ASP.NET?
In traditional web programming, it would be typically mean when every page is posted to server the associated values will be lost. This happens because every time page is posted to the server a new instance of page class is created. to overcome this situation state management technique is used. ASP.NET includes several methods to include the data after postback. These features are as follows.
- Client-Based State Management
- View state
- Hidden fields
- Query strings
- Server-Based State Management
- Application State
- Session State
- Profile Properties
Q8: What is Session State?
ASP.NET allows the save the data using session state. If different users are using the application, each user has a separate session state memory. Which means when one user leaves the system and another user will have different session state different from first.
Session state is maintained in the form of key, values pair for storing session-specific information. This would be useful to restore the values of each control while round trips to server happen.
Q9: What is Query String in ASP.NET?
Query string comes under client-based session management technique in ASP.NET. If a user wants to send values from one page(1.aspx) to another page(2.aspx) then query string is the best and easy approach.
If you look at below example code, here we are trying to pass two values namely first name, last name in “1.aspx” form.
protected void BtnSubmit_Click(object sender, EventArgs e)
Response.Redirect("1.aspx?firstname=" + Txt_FirstName.Text + "&lastname=" + Txt_LastName.Text);
In “2.aspx” web page using “Request.QueryString[“parameter_name“]” method, we can retrieve the value.
protected void Page_Load(object sender, EventArgs e)
string firstname = Request.QueryString["firstname"];
string lastname = Request.QueryString["lastname"];
Lbl_querystring.Text = "Query String Values: " + firstname + " " + lastname;
Q10: What are the different validators in ASP.NET?
- RequiredField Validator.
- Compare Validator.
- RegularExpression Validator.
- Range Validator.
- Custom Validator.
- Validation Summary.
Q11: What is a master page in ASP.NET?
Q12: What is caching?
Q13: What is the authentication and authorization in ASP.NET?
Q14: What is the web API in ASP.NET?
Q15: What is the difference between ASP.NET Web API and WCF?
Q16: What are the different types of caching?
Q17: What is the difference between Server.Transfer and Response.Redirect?
Q18: What is the base class for all Web Forms are inherited?
Q19: How can we apply Themes to an asp.net application?
Q20: How can we improve the Performance of an ASP.NET Web Page?
Youtube: ASP.NET Interview Questions and Answers
- ASP.NET Interview Questions.
- ASP.NET Interview Questions 2018.
- ASP.NET Interview Questions and Answers.
- ASP.NET Interview Questions and Answers 2018.
- ASP.NET Interview Question and Answers.
- ASP.NET Interview Question and Answers 2018.
- ASP.NET Interview Question.
- ASP.NET Interview Questions for experienced.
- ASP.NET Interview Questions for experienced 2018.
- ASP.NET Interview Questions top MNCs.
- ASP.NET Interview Questions and answers Top MNC FAQ.
- C# 8.0 Features