“ASP.NET is a web application development framework for building web sites and web applications that follows object oriented programming approach”
Following are the top 10 commonly asked Interview Questions with detailed answers on ASP.NET technology. I have also prepared a comprehensive Tutorial Series of ASP.NET Interview Questions that you can further read through to better prepare for your ASP.NET interview.
For a comprehensive list of ASP.NET MVC Interview Questions, follow here.
You can follow other Parts of this ASP.NET Interview Questions Series as:
- ASP.NET Interview Questions – Part 1 (Controls, State Management etc.)
- ASP.NET Interview Questions – Part 2 (Controls, Globalization & Localization etc.)
- ASP.NET Interview Questions – Part 3 (Caching & Security etc.)
- ASP.NET Interview Questions – Part 4 (Security)
- ASP.NET Interview Questions – Part 5 (ASP.NET AJAX)
- ASP.NET Interview Questions – Part 6 (ASP.NET Web API)
Build a Real World Application using ASP.NET Core and Angular 2
ASP.NET Interview Questions List
- What is the concept of Postback in ASP.NET?
- Difference between ASP.NET WebForms and ASP.NET MVC?
- Please briefly explain ASP.NET Page life Cycle?
- What is the difference between custom controls and user controls?
- What is the concept of view state in ASP.NET?
- Difference between Response.Redirect and Server.Transfer?
- Please briefly explain the usage of Global.asax?
- What are the different types of Validation controls in ASP.NET?
- What are the types of Authentication in ASP.NET?
- What are Session state modes in ASP.NET?
- We have just released a complete article series on Building an ASP.NET MVC Shopping Cart using MVC, C#, Entity Framework and SQL Server. Keep in touch to get the knowledge that how to create Online Shopping Store in ASP.NET MVC?, along with complete Source Code.
- The Complete ASP.NET MVC 5 Online Course : A review of a Best Seller ASP.NET MVC 5 by Mosh Hamedani (an Instructor with 5 star rating) that takes you from the beginning and helps you developing professional MVC Applications.
1. What is the concept of Postback in ASP.NET?
A postback is a request sent from a client to server from the same page user is already working with.
ASP.NET was introduced with a mechanism to post an HTTP POST request back to the same page. It’s basically posting a complete page back to server (i.e. sending all of its data) on same page. So, the whole page is refreshed.
In below diagram, when first request is made from client to server for a web page (say a simple registration form), IsPostback property value will be false. It will be a GET request that may be initiated by:
- typing a web page URL in a browser window or
- or, clicking a hyperlink on a webpage page.
Another concept related to this approach is “Callback” that is also asked sometimes during a technical interview question. Click here to understand Postback Vs Callback in ASP.NET.
2. Difference between ASP.NET WebForms and ASP.NET MVC?
ASP.NET Web Forms uses Page controller pattern approach for rendering layout. In this approach, every page has it’s own controller i.e. code-behind file that processes the request. On the other hand, ASP.NET MVC uses Front Controller approach. In this approach a common controller for all pages, processes the requests.
Please follow for detailed information on WebForms Vs MVC.
3. Please briefly explain ASP.NET Page life Cycle?
ASP.NET page passes through a series of steps during its life cycle. Following is the high-level explanation of life cycle stages/steps.
Initialization: Controls raise their Init event in this stage.Objects and variables are initializes for complete lifecycle of request.
LoadViewState: is a post back stage and loads the view state for the controls that enabled its view state property.
Load: In this stage page as well as all the controls raise their Load event. Till this stage all the controls are initialized and loaded. In most of the cases, we are coding this event handler.
RaisePostBackEvent: is again a postback stage. For example, it’s raise against a button click event. We can easily put our code here to perform certain actions.
SaveViewState: Finally, controls state is saved in this stage before Rendering HTML.
Render: This is the stage where HTML is generated for the page.
Dispose: Lastly, all objects associated with the request are cleaned up.
For very detailed explanation of Page Life Cycle is explained here.
Back to top
4. What is the difference between custom controls and user controls?
Custom controls are basically compiled code i.e. DLLs. These can be easily added to toolbox, so it can be easily used across multiple projects using drag and drop approach. These controls are comparatively hard to create.
But User Controls (.ascx) are just like pages (.aspx). These are comparatively easy to create but tightly couple with respect to User Interface and code. In order to use across multiple projects, we need to copy and paste to the other project as well.
Back to top
- A. Compiled Code (i.e. DLL)
- B. Tightly couple with respect to user interface and code.
- C. A bit hard to create.
- D. Can be easily used across multiple projects.
For a complete ASP.NET online test and Practice Exams, Click Here.
Correct Answer: A, C, D
5. What is the concept of view state in ASP.NET?
As in earlier question, we understood the concept of postback. So, in order to maintain the state between postbacks, ASP.NET provides a mechanism called view state. Hidden form fields are used to store the state of objects on client side and returned back to server in subsequent request (as postback occurs).
If we see the view source for an ASP.NET web page, we will find that hidden form field with Id = “__VIEWSTATE” something like the following:
Back to top
6. Difference between Response.Redirect and Server.Transfer?
In case of Response.Redirect, a new request is generated from client-side for redirected page. It’s a kind of additional round trip. As new request is generated from client, so the new URL is visible to user in browser after redirection.
While in case of Server.Transfer, a request is transferred from one page to another without making a round trip from client. For the end user, URL remains the same in browser even after transferring to another page.
Back to top
We have just released a complete article series on Building an ASP.NET MVC Shopping Cart using MVC, C#, Entity Framework and SQL Server. Keep in touch to get the knowledge that how to create Online Shopping Store in ASP.NET MVC?, along with complete Source Code.
7. Please briefly explain the usage of Global.asax?
Global.asax is basically ASP.NET Application file. It’s a place to write code for Application-level events such as Application start, Application end, Session start and end, Application error etc. raised by ASP.NET or by HTTP Modules.
There is a good list of events that are fired but following are few of the important events in Global.asax:
- Application_Init occurs in case of application initialization for the very first time.
- Application_Start fires on application start.
- Session_Start fires when a new user session starts
- Application_Error occurs in case of an unhandled exception generated from application.
- Session_End fires when user session ends.
- Application_End fires when application ends or time out.
8. What are the different types of Validation controls in ASP.NET?
In order to validate user input, ASP.NET provides validation server controls. All validation controls inherits from BaseValidator class which contains the common validation properties and methods like ControlToValidate, Enabled, IsValid, EnableClientScript, ValidationGroup,Validate() etc.
ASP.Net provides a range of validation controls:
- RequiredFieldValidator validates compulsory/required input.
- RangeValidator validates the range. Validates that input falls between the given range values.
- CompareValidator validates or compares the input of a control with another control value or with a fixed value.
- RegularExpressionValidator validates input value against a defined regular expression pattern.
- CustomValidator allows to customize the validation logic with respect to our application logic.
- ValidationSummary displays all errors on page collectively.
9. What are the types of Authentication in ASP.NET?
There are three types of authentication available in ASP.NET:
- Windows Authentication: This authentication method uses built-in windows security features to authenticate user.
- Forms Authentication: authenticate against a customized list of users or users in a database.
- Passport Authentication: validates against Microsoft Passport service which is basically a centralized authentication service.
10. What are Session state modes in ASP.NET?
ASP.NET supports different session state storage options:
- In-Process is the default approach. It stores session state locally on same web server memory where the application is running.
- StateServer mode stores session state in a process other than the one where application is running. Naturally, it has added advantages that session state is accessible from multiple web servers in a Web Farm and also session state will remain preserved even web application is restarted.
- SQLServer mode stores session state in SQL Server database. It has the same advantages as that of StateServer.
- Custom modes allows to define our custom storage provider.
- Off mode disables session storage.
Top 10 Web Developer Interview Questions Series:
- Top 10 ASP.NET AJAX Interview Questions
- Top 10 WCF Interview Questions
- Comprehensive Series of WCF Interview Questions
- Top 10 HTML5 Interview Questions
- Top 10 ASP.NET Interview Questions
- Comprehensive Series of ASP.NET Interview Questions
- Top 10 ASP.NET MVC Interview Questions
- Top 10 ASP.NET Web API Interview Questions
Which company is best for Matrimony
What is the difference between static gridview and dynamic gridview and how can i understtand it