21
nov.Top 50 ASP.NET Interview Questions and Answers
ASP.NET Interview Questions
In the ever-evolving landscape of web development, ASP.NET stands as a stalwart framework, empowering developers to craft robust and dynamic web applications. Aspiring developers and seasoned professionals alike often find themselves traversing the labyrinth of interviews, where knowledge reigns supreme. To embark upon this journey prepared, let's delve into a comprehensive array of ASP.NET interview questions and answers, illuminating the path to mastery.
Whether you're seeking to bolster your expertise or preparing for an ASP.NET Core Certification Training, a solid understanding of the framework's intricacies is paramount.
Basic ASP.NET Interview Questions
1. What is web application?
Web application is an application that is deployed remotely and can be accessed over network (network can be intranet or internet).
Web application accessed through the browsers.
2. Which languages are supported for ASP.NET development?
ASP.NET supports various languages including C#, VB.NET, earlier it was supported to J# also but after some time the supported was removed as it was not that much used.
C# is an object-oriented programming language created by Microsoft that supports .NET Framework.
VB.NET (Visual Basic .NET) a programming language supports object oriented features, which was developed by Microsoft in 2002.
3. Which IDE is used to developed ASP.NET Web application?
Visual studio is the official IDE that has the full support to ASP.NET web application including intelligence, apart from the VS studio, Sharp Develop like alternative exist in the market but not so popular.
4. What are the common features of ASP.NET?
Ease to development: ASP.NET is well known for the ease to development, it provides lot of ready to use controls that can be easily drag drop for design purpose.
Stability: ASP.NET is also well known for its stability it is most the stable framework in the history of .NET technology, enterprise level big application can be easily handled by ASP.NET.
Performance: it is faster than traditional web application like ASP, also its newer version (ASP.NET Core) is faster than ASP.NET.
Compatibility: ASP.NET can be integrated with JavaScript, CSS, HTML5 and bootstrap libraries.
5. Which is the latest version of ASP.NET? how it is useful to us?
ASP.NET Core is the next version of ASP.NET, ASP.NET Core is first released on 2016, it has lot of benefits over traditional ASP.NET.
Cross Platform: The latest version of ASP.NET can be deployed on multiple platform including Windows, Mac and Linux, whereas classic ASP.NET is only compatible to Windows.
Open Source: it is open source technology, where the code is shared on GitHub, it leads to lot of significant contribution by developers around the world and faster bug-fixes, patches and improvements is possible.
High Performance: now a day it is one of the faster web application framework.
6. When to choose latest version of ASP.NET (.NET Core) instead of classic ASP.NET?
- When you need cross-platform support for your Web app
- When you need robust and stable environment to work in
- Want a compatibility with other tools and framework (Angular)
- Have a team with knowledge of latest technologies
7. explain basic architecture of ASP.NET?
The basic structure is divided in 3 parts
1. CLR: Common language runtime.
2. Library: A set of common standard libraries.
3. Language: Set of supported languages like VB and C#.
8. Explain the use of CLR ?
This is basically a known as Common Language Runtime, it manages the actual execution of program, it converts source code into Common Intermediate Language (CIL),
it is a virtual machine component of the .NET, it does below tasks
- Memory management
- Type safety
- Exception handling
- Garbage collection
- Security
- Thread management
9. What is web server? it is necessary for ASP.NET?
Web server is a services/application that allows to deploy the asp.net application, there are many web servers exist for Windows it is IIS, ASP.NET application can be host on IIS,
IIS: it is the Inbuilt services of windows; it is known as internet Information Services. IIS is responsible for getting request from client browser and send back the response.
10. How ASP.NET communicate with web server?
ASP.NET works on classical client-server model. Where A Sender (client), make a request using web browser, then waits till it receives a response from the server.
11. What are the web forms in ASP.NET?
Web forms are web pages built on ASP.NET Technology. They are compiled and executed on the server, which generates the HTML that displays the web pages. Web forms can be created using HTML, client-script, server controls, and server code.
Web forms applications can be written in any programming language which supports the Common Language Runtime, such as C# or Visual Basic.
12. Name some of the common controls used in ASP.NET?
Radio Button: This helps user to choose between the different options.
Text Box: This is input control, allows users to enter text. It's a single-line-textbox by default, but you can customize it with many properties.
Button: This is push button, allow user to execute any action on web form.
Checkbox: Indicates whether a particular condition is on or off. It's commonly used to present a Yes/No as well as True/False selection to the user.
Hyperlink: Creates a hyperlink control that responds to a click event.
13. What is .csproj in web forms in asp.net?
It is a project file for .NET projects, It's an XML file that contains information and instructions that MSBuild needs to build a project. It includes:
A list of files in the project and References to system assemblies.
14. What is ASP?
A programming language that allows users to run scripts on a web server. ASP is a server-side script engine that can contain scripts and standard HTML. ASP files have the extension ".asp"
15. How ASP is different than ASP.NET?
- ASP: ASP is partially object-oriented.
- ASP.NET is purely object-oriented.
- ASP has mixed HTML and coding logic
- ASP.NET separates the HTML and coding part by code behind files.
- ASP is vulnerable to application crashes
- ASP.NET has a separate process space that avoids application crashes.
- ASP can't run on Apache webserver and other non-Microsoft-based technology platforms
- With the help of some third party supported component ASP.NET can give support to Apache
16. How HTTP protocol works in ASP.NET?
HTTP is an application layer protocol that runs on top of the TCP/IP suite of protocols, which forms the foundation of the internet. It works by exchanging resources between client devices and servers over the internet.
ASP.NET takes use of HTTP to transfer the information between client and server, it also takes use of basic HTTP features like Caching, proxy, Authentication, Session.
17. What is .SLN file in ASp.NET?
A .sln file contains information about the organization of projects in a solution file. The contents of a solution file are written in plain text and can be edited by opening the file in any text editor.
A .sln file loads the solution, projects within the solution, and any persisted information attached to the solution.
ASP.NET Interview Questions for Intermediate
18. Which configuration file is used in ASP.Net?
Web.Config is used to configure the application related settings in ASp.NEt, basically A Web.Config file is an XML-based configuration file used to define an application's custom settings. It is used to configure an app hosted with IIS. you can say it is a mirror copy to IIS settings
The Web.Config file can include settings such as: Authentication, Authorization, Membership Provider, Role Provider, Profile Provider Settings.
19. What is Global.Asax file in asp.net?
Global.Asax is an optional file in ASP.NET that handles events raised by ASP.NET, Global.Asax is useful for application-level functionality, such as unhandled exception logging. It's mostly used for application and session start/end events and for global error handling.
Some important events that can be intercepted in the Global.Asax file include:
Application_Init, Application_Start, Application_Error, Application_BeginRequest, Application_EndRequest, Session_Start, Session_End.
20.What is Caching?
Caching is a mechanism that stores frequently accessed data in memory so that it can be directly obtained when the same data is needed again. This reduces the time it takes to render a page, improving page response time.
ASP.NET also supports output caching, which stores the generated output of pages, controls, and HTTP responses in memory.
21. How to transfer values between one page to another in asp.net?
With the help of state management, you can transfer values between pages, there are two types of state management
1. Client-Side state management
2. Server-Side state management
22. What is nuget package manager?
Basically To import any external libraries and dependencies in your .NET projects you can take use of NuGet package manager, It allows to import and manage packages.
The NuGet Gallery is where all the packages live. It’s a central repository where developers can share their packages with the entire .NET community.
23. What is User control in ASP.NET ?
When you want to enhances code reusability and modularity you can take use of user control, A User Control (often denoted by the .ascx extension) is a reusable component in ASP.NET.
It combines both markup (HTML-like content) and server-side code (usually written in C# or VB.NET).
Whenever you want to show common UI element on each ASPX page, instead of repeating common UI control on each page, you can use user control, Centralized Maintenance is also possible.
24. What is difference between user control and custom control?
User Control
- Having extension as ASCX
- Simple to create
- Can be used just by drag drop, it will automatically get registered
- Ideal when you want to use Within the Same Web Application
- Ideal when you want to create a header or footer in your whole application
Custom Control
- Provide more flexibility, reusability, and customization options.
- Having extension as .dll
- No language dependency, means you can create it with vb.net and use it in c#.net application
- Ideal when you want to use it across multiple web application
25. What is cookies in ASP.NET?
Cookies are a client-side management technique, that is used to maintaining state between request, A cookie is a small piece of text data that a web server sends to the client’s browser.
These cookies are stored locally on the user’s hard disk.
There are 2 types if cookies:-
1. Permanent Cookies : It doesn’t have an expiration time. It remains on the client machine until explicitly removed. Mainly used to store page theme or language selection.
2. Temporary Cookies : It remains valid only until that time, mainly used to store like session like thing.
Look at below sample of cookies
//store the cookies
HttpCookie loginInfo = new HttpCookie("MyCookie");
userInfo["UserName"] = "dotnet";
userInfo["UserColor"] = "tricks";
userInfo.Expires = DateTime.Now.AddMinutes(1);
Response.Cookies.Add(loginInfo);
//retrive stored cookies
string userName = Request.Cookies["userName"]?.Value;
26. What is ViewState in ASP.NET?
View state is a client-side page level state management, it is used to store page level state, it is an encrypted text, that store the state for each control including hidden fields, these strings are stored in a hidden input field named _VIEWSTATE.
It allows you to retain the values of input controls such as textboxes, checkboxes, radio button, dropdown list etc. across post backs.
27. What is JSON?
JSON, or JavaScript Object Notation, is a text-based format for storing and transmitting data. JSON is a popular standard for data interchange because it is easy for humans to read and lightweight.
As ASP.NET has Web.Config file for string configuration, in latest version of ASP.NET that ASP.NET Core we can store file in JSON.
28. How to load .JS file in ASPX page?
use the script tag in ASPX to load the external scripting in an application check below syntax.
<script src='path of JS file' type="text/javascript"></script>
29. What are the Directives in ASP.NET?
Directives are basically top level statement that applicable to particular scope, there are many directives exist in the ASP.NET but here are some important directives.
@Page: Basically these are top level instruction and page level settings of ASPX that are applicable to that particular page only.
it is denoted by @Page keyword.
@Master: It is similar to @Page directive but used for master page
@Control: this is used for user control
@Import: when you want to import any name space in ASPX
@Register: to registered custom or user control
@Output Cache: it manages the different parameters of output caching
30. What are the different data Bound controls in asp.net?
1. GridView Control
This is a popular control to show the data at UI, it displays data in tabular format and it has the capability to sorting the data, editing data. We can place controls on it.
2. Details View Control
The Details View control renders a single record at a time as a table and provides the capability to page through multiple records, as well as to insert, update, and delete records.
3. FormView Control
The FormView control renders a single record at a time from a data source and provides the capability to page through multiple records, as well as to insert, update, and delete records, similar to the Details View control.
31. Can i use LINQ in ASP.NET?
Yes, you can use Language-Integrated Query (LINQ) in Web pages to retrieve and modify data, it will help to travel the data faster
'asp:LinqDataSource' can be used to connect to LINQ
32. What is LINQ?
Language-Integrated Query better known as LINQ is a technology, basically it is the integration of query capabilities in programming language. It supports filtering, sorting, ordering, grouping of data, it does introduce in .NET framework 3.5 It makes easy debugging because it is integrated with C# language.
33. Popular events of grid view controls in ASp.NET?
RowDataBound : Occurs when a data row is bound to data in a GridView control.
PageIndexChanging : call when there is paging is used in grid view
RowCommand : fires when we click any button on gridview
RowDeleted : Occurs when a row's Delete button is clicked, but after the GridView control deletes the row.
RowUpdated : Occurs when a row's Update button is clicked, but after the GridView control updates the row.
34. How to clear ASP.NET gridview?
Just by assigning the null value to DataSource you can make the gridview clear
grdResultados.DataSource = null;
grdResultados.DataBind();
ASP.NET Interview Questions for Experienced
35. What you mean by Event bubbling in Asp.Net?
Event bubbling in ASP.NET is a mechanism that allows the handling of child control events through their parent control in data-bound controls, in simple words, when an event occurs in a child control (such as a button click), the event is propagated or “bubbled” up to the parent control.
36. What is Application object in ASP.NET?
It is a server based state management technique, which store the values in Application object. The Application object is used to store and access variables that are shared across multiple pages within the same web application. It serves as a global container for information that needs to be accessible throughout the application’s lifetime.
37. What is try catch?
When an exception occurs during program execution (such as invalid array index), it can lead to program disorder, here try catch help you.
The try block allows you to enclose code that might generate an exception, the catch block handles the exception if it occurs within the try block.
38. What are the HTML server controls?
HTML server controls are nothing but an inbuilt HTML control with runat=server attribute so that they can be accessible in ASP.NET backend CS file
39. What is the difference between web server control vs HTML server control?
HTML server controls are lightweight and follow an HTML-centric model, web server controls (ASP.NET Server Controls) offer more features, better compatibility, and higher abstraction. Choose the one that best suits your development need.
HTML Server Controls
These are HTML elements that include a runat="server" attribute.
The object model of HTML server controls closely maps to the HTML elements they render.
They provide automatic state management and server-side events.
Web Server Controls (also known as ASP.NET Server Controls)
These controls offer more built-in features compared to HTML server controls.
They can detect the target browser’s capabilities and render themselves accordingly.
No compatibility issues with different browsers; the controls adapt automatically.
40. What is AJAX?
AJAX stands for Asynchronous JavaScript and XML. It’s a powerful web development technique that allows you to create dynamic and responsive web applications.
41. What are the features of AJAX?
- Asynchronous: AJAX allows web pages to communicate with the server asynchronously.
- Dynamic Page Updates: AJAX enables updating specific parts of a web page without reloading the entire page.
- Client side rendering: AJAX supports client-side template rendering
- Live data binding: hangs in data reflect immediately in the UI
- lower server load: By updating only specific portions of a page, AJAX reduces server resource consumption
42. How to handle exception in asp.net?
There are multiple ways to handle exception in asp.net
1. using TRY.CATCH. FINALLY
The try-catch statement consists of a try block and either a catch block, a finally block, or both.
Execution flow:
Code within the try block runs first.
If an exception occurs, the catch block handles it.
The finally block always executes before exiting the construct.
e.g.
try {
// Code that might throw an exception
} catch (error) {
// Handle the exception
} finally {
// Code that always executes
}
43. What Application_error event?
The Application_Error event occurs in the Global.Asax file (also known as the Global Application Class).
It is triggered when an unhandled exception occurs during the execution of an ASP.NET application.
Essentially, it provides a centralized place to handle unexpected errors that might otherwise crash the application
44. What is session_error event?
This event exists in Global.Asax basically this event indicates that there is a problem with the current session. The event is forwarded to all clients that are interested in the event.
45.What are the inbuilt validator for ASP.NET Web forms?
ASP.NET Web Forms has a set of validation server controls that handle validating user input entered into a form. Validation controls ensure that user input data is valid, secure, and accurate
some of the validators are :-
RequiredFieldValidator: this validator checks if required field is not empty.
CompareValidator: this validator compares a value in one control with a fixed value or a value in another control.
RangeValidator: check if the input value is between the specified range.
RegularExpressionValidator: RegularExpressionValidator allows validating the input text by matching against a pattern of a regular expression.
CustomValidator: We can write application specific custom validation routines.
ValidationSummary: This Control does not perform any validation but shows a summary of all errors in the page.
46. What are the authentication exist in ASP.NET?
Windows Authentication
Form Authentication
Custom Authentication
Passport Authentication
47. What is the impersonation in IIS?
In ASP.NET, impersonation is the ability to use a user's Windows identity to run applications. ASP.NET impersonation is often used in applications that rely on Microsoft Internet Information Services (IIS) to authenticate the user.
ASP.NET configuration file Web.Config has the related tags about it
<configuration>
<system.web>
<identity impersonate=``true''/>
</system.web>
</configuration>
48. What is the use of Web.Config?
A Web.Config file is a configuration file that manages website settings. It's an XML-formatted file that can be used to configure applications. The file can be used to define configurations during development, deployment, and after deployment. It can also be used to override default configurations
Configure application security
Configure SQL database connection
Configure session types and duration
Configure the modules in the HTTP pipeline
Configure HTTP handlers
Configure WCF services interoperability
Customize the application context
49. What is the use of Global.Asax?
Global.Asax is an optional file that contains code for responding to application-level events raised by ASP.NET or by HTTP modules. These events include: Application starting, Session ending, Application error.
Global.Asax is located in the root directory of an ASP.NET application. It's derived from the HttpApplication class and maintains a pool of HttpApplication objects, and assigns them to applications as needed.
Global.Asax files are never called directly by the user, rather they are called automatically in response to application events
50. What is application pool in iis?
An application pool in Internet Information Services (IIS) is a collection of applications or websites that are served by one or more worker processes with the same configuration
Application pools are used to:
Isolate web applications
Allow different configurations, such as resource usage and security
Prevent misbehaving applications from interfering with other applications
Improve security, performance, stability, and reliability
Make maintenance easier
Conclusion
It’s common to feel nervous before and during an interview, Preparation, planning, and rehearsing help reduce this anxiety, When you arrive well-prepared, it shows your dedication and genuine interest in the position and company, also Preparation allows you to hone your skills, improve your performance, and increase your chances of standing out. These 50 ASP.NET Interview questions will help you to crack your interview. These interview question breaks in 3 part for beginners, intermediate and advanced.
Whether you're embarking on your journey toward an ASP.NET Core Certification Course or aiming to solidify your expertise in ASP.NET, these questions cover a wide spectrum, ensuring comprehensive preparation regardless of your proficiency level.
FAQs
Q1. What is ASP.NET full form?
Q2. Is ASP.NET easy?
Q3. Why is ASP.NET used?
Q4. Is ASP.NET good for the future?
Q5. Is ASP.NET good for backend?
Take our free skill tests to evaluate your skill!
In less than 5 minutes, with our skill test, you can identify your knowledge gaps and strengths.