1. What is .NET?
Answer: .NET is a framework for software development. It is just like other software development framework like (J2EE). It provides runtime capabilities and a rich set of pre-built functionality in the form of a class library and APIs. This .NET framework is an environment to build, deploy and run web services and other applications.
The .NET framework contains three main parts:
Common Language Runtime
2. What are tuples in .Net?
Answer: A tuple is a fixed-size collection that can have elements of either the same or different data types. The user must have to specify the size of a tuple at the time of declaration just like arrays.
3. What are Web Services in ASP.NET?
Answer: A Web Service is a software program that uses XML to exchange information with other software via common internet protocols. In a simple sense, Web Services are a way of interacting with objects over the Internet.
A web service is:
- Protocol Independent.
- Platform Independent.
It assumes a stateless service architecture.
Scalable (e.g. multiplying two numbers together to an entire customer-relationship management system).
Programmable (encapsulates a task).
Based on XML (open, text-based standard).
Self-describing (metadata for access and use).
Discoverable (search and locate in registries)- the ability of applications and developers to search for and locate desired Web services through registries. This is based on UDDI.
Key Web Service Technologies:
XML- Describes only data. So, any application that understands XML-regardless of the application’s programming language or platform has the ability to format XML in a variety of ways (well-formed or valid).
SOAP- Provides a communication mechanism between services and applications.
WSDL- Offers a uniform method of describing web services to other programs.
UDDI- enables the creation of searchable Web services registries.
4. What are the Advantages of ASP.NET?
Answer: ASP.NET provides services to allow the creation, deployment, and execution of Web Applications and Web Services like ASP, ASP.NET is a server-side technology. Web Applications are built using WebForms. ASP.NET comes with built-in Web Form controls, which are responsible for generating the user interface. They mirror typical HTML widgets such as text boxes or buttons. If these controls do not fit your needs, you are free to create your own user controls.
Advantages of ASP.NET:
- Separation of Code from HTML
- Support for compiled languages
- Use services provided by the .NET Framework
- Graphical Development Environment
- Update files while the server is running
- XML-Based Configuration Files
5. How many elements a tuple can hold?
Answer: A tuple can hold up from 1 to 8 elements. In the case of more than 8 elements, then the 8th element can be defined as another tuple. Tuples can be specified as a parameter or return type of a method.
6. What is the difference between the Hash table and Array list?
Answer: Hash table stores data in the form of value pair and name while Array list stores only values.
You need to pass the name to access value from the Hash table while in Array, you need to pass the index number to access value.
In Array, you can store only a similar type of data type while in the Hash table you can store different type of data types. ex. int, string, etc.
7. What is the difference between namespace and assembly?
Answer: An assembly is a physical grouping of logical units while namespace groups classes. A namespace can span multiple assemblies.
8. Is ASP.NET different from ASP? If yes, explain how?
Answer: Yes, ASP.NET is different from ASP. These are the main differences:
ASP.NET is developed by Microsoft to create dynamic web applications while ASP (Active Server Pages) is a Microsoft’s server-side technology used to create web pages.
ASP.NET is compiled while ASP is interpreted.
ASP uses the technology named ADO while ASP.NET uses ADO.NET.
ASP.NET is completely object-oriented while ASP is partially object-oriented.
9. Which ASP.NET objects encapsulate the state of the client and the browser?
Answer: The Session object encapsulates the state of the client and browser.
10. What is variable and constant in the .NET programming language?
Variable: A variable is a data storage location in the computer memory that contains a value and has a meaningful name. Every variable is attached to a data type which determines what type of value can be stored in the variable.
Variables can be declared by using the following syntax:
Constant: Constant is also similar to the variable except that the value. Value once assigned to a constant can’t be changed. Constants must be initialized at the same time they are declared.
Constants can be declared by using the following syntax:
const int interestRate =10;
11. How do you validate the controls in an ASP .NET page?
Answer: Using special validation controls that are meant for validation of any control.
We have Range Validator, Email Validator in .NET to validate any control.
12. Describe login Controls in ASP?
Answer: The Login control provides the user interface to log a user into a web site. The Login control uses the Membership service to authenticate the user in your membership system. The default Membership service from your configuration file will be used automatically, however, you can also set the Membership provider that you would like used as a property on the control.
The Login Control consists of:
Username Label and Textbox: Collects the string used to identify the user in the membership system.
Password Label and Textbox: Collects the password for the specified user. The textbox text is always obscured.
LoginButton: The button to submit the user’s request for authentication.
RememberMe: Configurable to display a checkbox giving the user the option to store a persistent cookie on the user’s machine.
Title and Instruction: Text to orient and guide the user through the process.
Links: Configurable links to help, password recovery and user registration information.
Validators: Required field Validators for the username and password textboxes.
13. How to use repeater control in ASP.NETP?
Answer: A Repeater is a Data-bound control. Data-bound controls are container controls. It creates a link between the Data Source and the presentation UI to display the data. Repeater control is used to display a repeated list of items.
The main use of Repeater Control is for displaying a repeated list of items bound to the control. A Repeater Control is faster and lightweight for displaying data compared to a GridView or DataGrid. With the Repeater control, we can display data in a custom format. The main drawback of a Repeater Control is that it doesn’t support paging and sorting.
The Repeater Control has the following types of template fields:
- Item Template
- AlternatingItem Template
- Header Template
- Footer Template
- Separator Template
Write connection code and select command in code behind file like:
protected void Page_Load(object sender, EventArgs e)
SqlConnection con = new SqlConnection(“Data Source=MCNDESKTOP34;Initial Catalog=yatendra;Persist Security Info=True;User ID=sa;
14. If you want to replace multiple if-else statements in code, which statement will you use?
Answer: In Visual basic, we can use Select-Case statement to replace multiple If-Else statements. In C#, we should use Switch-Case statement to replace multiple If-Else statements.
15. What are different methods of session maintenance in ASP.NET?
Answer: The session is a State Management Technique. A Session can store the value on the Server. It can support any type of object to be stored along with our own custom objects. A session is one of the best techniques for State Management because it stores the data as client-based, in other words, the data is stored for every user separately and the data is secured also because it is on the server.
We can set the session on one of the following 2 types of configuration files:
Machine Configuration file: Machine Configuration is applied for all application.
Application Configuration file: It’s applied for only application by application basis.
Application Configuration file
In ASP.NET there are 4 types of Session Mode.
Off: We can disable the session mode for the entire application using the off mode.
According to performance and durability, the difference between InProc, State Server and SQL Server is:
Session mode Performance Durability
InProc More(1 processor and 1 server) less.
State Server Medium(n processor and 1 server) Medium
16. What is the difference between session and caching?
Answer: The first main difference between session and caching is: a session is per-user based but caching is not per-user based, So what does that mean? Session data is stored at the user level but caching data is stored at the application level and shared by all the users. It means that it is simply session data that will be different for the various users for all the various users, session memory will be allocated differently on the server but for the caching-only one memory will be allocated on the server and if one user modifies the data of the cache for all, the user data will be modified.
17. What is a flat-file?
Answer: A flat file is a name given to text, which can be read or written only sequentially.
18. What is a managed extensibility framework?
Answer: Managed extensibility framework (MEF) is a new library that is introduced as a part of .NET 4.0 and Silverlight 4. It helps in extending your application by providing greater reuse of applications and components. MEF provides a way for the host application to consume external extensions without any configuration requirement.
19. What is the concepts of Globalization and Localization in .NET?
Answer: Localization means “process of translating resources for a specific culture”, and Globalization means “process of designing applications that can adapt to different cultures”.
Proper Globalization: Your application should be able to Accept, Verify, and Display all global kind of data. It should well also be able to operate over this data, accordingly. We will discuss more this “Accordingly operations over the diff. culture data”.
Localizability and Localization: Localizability stands for clearly separating the components of culture-based operations regarding the user interface, and other operations from the executable code.
The .NET framework has greatly simplified the task of creating applications targeting the clients of multiple cultures. The namespaces involved in the creation of globalizing, localizing applications are:
20. What are the functional and non-functional requirements?
Answer: Functional requirements define the behavior of a system whereas non-functional requirements specify how the system should behave; in other words, they specify the quality requirements and judge the behavior of a system.
Functional – Display a chart which shows the maximum number of products sold in a region.
21. What is shadowing?
Answer: Shadowing is either through a scope or through inheritance. Shadowing through inheritance is hiding a method of a base class and providing a new implementation for the same. This is the default when a derived class writes an implementation of a method of the base class which is not declared as overridden in the base class. This also serves the purpose of protecting the implementation of a new method against subsequent addition of a method with the same name in the base class.’ shadows’ keyword is recommended although not necessary since it is the default.
22. What is the difference between HttpContext?Current.Items and HttpContext.Current.Session in ASP.NET?
Answer: Session state is one of the popular state management techniques in ASP.NET environment. We, developer people, play with session storage every now and then. It’s pretty simple to manage session if you understand the basic concept. Here is the syntax to do that.
Session[index] = ”Value”;
Let’ s a have an example: using System;
public partial class WebForm1: System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
HttpContext.Current.Items[“Value”] = “Sourav Kayal in ITEM”;
HttpContext.Current.Session[“Value”] = “Sourav Kayal in SESSION”;
Response.Write((string)(HttpContext.Current.Items[“Value”]) + “
protected void Button1_Click(object sender, EventArgs e)
Response.Write((string)(HttpContext.Current.Items[“Value”]) + “
23. What is the difference between Server.Transfer and Response.redirect?
Answer: Both Response.Redirect and Server. Transfer methods are used to transfer a user from one web page to another web page. Both methods are used for the same purpose but still, there are some differences as follows.
The Response. Redirect method redirects a request to a new URL and specifies the new URL while the Server. Transfer method for the current request terminates execution of the current page and starts execution of a new page using the specified URL path of the page.
Both Response.Redirect and Server.
The transfer has the same syntax as:
Before touching on more points I want to explain some HTTP status codes, these are important for the understanding of the basic differences between these two. The HTTP status codes are the codes that the Web server uses to communicate with the Web browser or user agent.
For further info click on the link:
Difference Between Response.Redirect() and Server.Transfer() Methods in ASP.Net
24. Which architecture does a Dataset follow?
A Dataset follows disconnected data architecture.
25. What is caching in ASP.NET?
Answer: Caching is one of the most interesting concepts and operation in ASP.NET. If you can handle it, you can run any web application by applying the caching concept depending on the requirements.
Caching is for providing solutions or the results to the users depending on their request, the admin needs to recreate the pages often depending on user requests…STOP!!! “A cache simply stores the output generated by a page in the memory and this saved output (cache) will serve us (users) in the future.”.
26. What is the authentication and authorization in ASP.NET?
Authentication: Prove genuineness
Authorization: the process of granting approval or permission on resources.
In ASP.NET authentication means to identify the user or in other words it’s nothing but to validate that he exists in your database and he is the proper user.
Authorization means does he have access to a particular resource on the IIS website. A resource can be an ASP.NET web page, media files (MP4, GIF, JPEG etc), compressed file (ZIP, RAR), etc.
authentication and authorization
Types of authentication and authorization in ASP.NET
There are three ways of doing authentication and authorization in ASP.NET:
Windows authentication: In this methodology ASP.NET web pages will use local windows users and groups to authenticate and authorize resources.
Forms Authentication: This is a cookie-based authentication where username and password are stored on client machines as cookie files or they are sent through URL for every request. Form-based authentication presents the user with an HTML-based Web page that prompts the user for credentials.
Passport authentication: Passport authentication is based on the passport website provided by Microsoft. So when user logins with credentials it will be reached to the passport website ( i.e. Hotmail,devhood, windows live etc) where authentication will happen. If Authentication is successful it will return a token to your website.
Anonymous access: If you do not want any kind of authentication then you will go for Anonymous access.
In ‘web.config’ file set the authentication mode to ‘Windows’ as shown in the below code snippets.
We also need to ensure that all users are denied except authorized users. The below code snippet inside the authorization tag that all users are denied. ‘?’ indicates any unknown user. (.net Training Online)
27. Difference between Abstract Classes and Interfaces?
Following are the differences between Abstract Classes and Interfaces:
a) When a derived class is inherited from an Abstract class, no other class can be extended then. The interface can be used in any scenario.
b) Abstract class contains an abstract method, i.e. actual implementation logic. On the other hand, interfaces have no implementation logic.
c) Every method in an interface must be abstract. This is not necessary in the case of abstract classes.
28. What is the App Domain Concept in ASP.NET?
Answer: ASP.NET introduces the concept of an Application Domain which is shortly known as AppDomain. It can be considered as a Lightweight process which is both a container and boundary. The .NET runtime uses an AppDomain as a container for code and data, just like the operating system uses a process as a container for code and data. As the operating system uses a process to isolate misbehaving code, the .NET runtime uses an AppDomain to isolate code inside a secure boundary.
The CLR can allow the multiple .NET applications to run in a single AppDomain. Multiple Appdomains can exist in Win32 process.
How to create AppDomain: AppDomains are created using the CreateDomain method. AppDomain instances are used to load and execute assemblies (Assembly). When an AppDomain is no longer in use, it can be unloaded.
public class MyAppDomain: MarshalByRefObject
public string GetInfo()
public class MyApp
public static void Main()
AppDomain apd = AppDomain.CreateDomain(“Rajendrs Domain”);
MyAppDomain apdinfo = (MyAppDomain) apd.CreateInstanceAndUnwrap(Assembly.GetCallingAssembly()
Console.WriteLine(“Application Name = ” + apdinfo.GetInfo());
29. What is Query String in ASP?
Answer: A QueryString is a collection of characters input to a computer or web browser. A Query String is helpful when we want to transfer a value from one page to another. When we need to pass content between the HTML pages or aspx Web Forms in the context of ASP.NET, a Query String is Easy to use and the Query String follows a separating character, usually a Question Mark (?). It is basically used for identifying data appearing after this separating symbol. A Query String Collection is used to retrieve the variable values in the HTTP query string. If we want to transfer a large amount of data then we can’t use the Request.QueryString. Query Strings are also generated by form submission or can be used by a user typing a query into the address bar of the browsers.
Syntax of Query String
Simple to Implement
Easy to get information from the Query string.
Used to send or read cross-domain (from a different domain).
Client browser limit on URL length
Cross paging functionality makes it redundant
Easily modified by end-user.
30. What are the major events in global.aspx?
Answer: The Global.asax file, which is derived from the HttpApplication class, maintains a pool of HttpApplication objects, and assigns them to applications as needed. The Global.asax file contains the following events:
31. Use of CheckBox in .NET?
Answer: The CheckBox control is a very common control of HTML, unlike radio buttons, it can select multiple items on a webpage. The CheckBox control in ASP.NET has many properties and some of them are listed below.
AutoPostBack Specifies whether the form should be posted immediately after the Checked property has changed or not. The default is false.
CausesValidation Specifies if a page is validated when a Button control is clicked.
Checked Specifies whether the checkbox is checked or not.
InputAttributes Attribute names and values used for the Input element for the CheckBox control.
LabelAttributes Attribute names and values used for the Label element for the CheckBox control.
run at Specifies that the control is a server control. Must be set to “server”.
Text The text next to the checkbox.
TextAlign On which side of the checkbox the text should appear (right or left).
ValidationGroup Group of controls for which the Checkbox control causes validation when it posts back to the server.
OnCheckedChanged The name of the function to be executed when the Checked property has changed.
For further info click on the link:
Use CheckBox inside Gridview in ASP.NET
32. What are the authentication modes in ASP.NET for security?
Answer: When you begin a program for a customer using ASP.NET, you should consider about security. Security is one of the most important components of any application. Security is even more important when you are making a web application which is exposed to millions of users. ASP.NET provides classes and methods that ensure that the application is secure from outside attacks. In this article, we will investigate the different types of authentication provided by ASP.NET. In web.config file you can set authentication mode value ‘windows’ or ‘forms.
33. What is manifest in the .NET Framework?
Answer: Manifest is used to store assembly metadata. It contains all the metadata which are necessary for the following things.
Version of assembly
Scope of the assembly
To resolve references to resources and classes
34. What is the ASP.NET page life cycle?
Answer: When a page is requested by the user from the browser, the request goes through a series of steps and many things happen in the background to produce the output or send the response back to the client. The periods between the request and response of a page is called the “Page Life Cycle”.
Request: Start of the life cycle (sent by the user).
Response: End of the life cycle (sent by the server).
There are four stages that occur during the Page Life Cycle before the HTML Response is returned to the client. Later in this article we”ll study all these stages and their sub-events.
Initialization During this stage the IsPostback property is set. The page determines whether the request is a Postback (old request) or if this is the first time the page is being processed (new request). Controls on the page are available and each control’s UniqueID property is set. Now if the current request is a postback then the data has not been loaded and the value of the controls have not yet been restored from the view state.
Loading At this stage if the request is a Postback then it loads the data from the view state.
Rendering Before rendering, the View State is saved for the page and its controls. During this phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page’s Response property.
Unloading Unload is called after the page has been fully rendered, sent to the client and is ready to be discarded. At this point also the page properties such as Response and Request are unloaded.
35. How to use mode “Windows”?
Answer: Windows Authentication mode provides the developer to authenticate a user based on Windows user accounts. This is the default authentication mode provider by ASP.NET. This will return the computer name along with the user name.
36. What is the web API in ASP.NET?
Answer: It is a framework provided by Microsoft for writing HTTP services. There are many frameworks available to build HTTP based services. They follow a common guideline of international standardization but with different flavors.
For example, all framework must adhere to these status codes-
1xx – Informational Message
2xx – Successful
3xx – Redirection
4xx – Client Error
5xx – Server Error
It is lightweight and thus good for small devices also like tablets, smartphones.
No tedious & extensive configuration like WCF REST is required.
MediaTypeFormatter makes easy to configure your APIs response type in single line (JSON, XML and so on).
IIS Hosting dependency is no more and it can be hosted in the application too.
Easy and simple control with HTTP features such as Caching, Versioning, request/response headers, and its various content formats.
It supports content-negotiation (deciding the best response data format that the client can accept).
37. What is code access security (CAS)?
Answer: Code access security (CAS) is part of the .NET security model that prevents unauthorized access of resources and operations and restricts the code to perform particular tasks.
38. What is the role of the DataSet object in ADO.NET?
Answer: One of the major components of ADO.NET is the DataSet object, which always remains disconnected from the database and reduces the load on the database.
39. What is page directives in ASP.NET?
Answer: Basically Page Directives are commanded. These commands are used by the compiler when the page is compiled.
How to use the directives in an ASP.NET page
It is not difficult to add a directive to an ASP.NET page. It is simple to add directives to an ASP.NET page. You can write directives in the following format:
See the directive format, it starts with “<%@” and ends with “%>”. The best way is to put the directive at the top of your page. But you can put a directive anywhere in a page. One more thing, you can put more than one attribute in a single directive.
Here is the full list of directives:
40. What is an HTTP handler?
Answer: Handler is a low-level request and response API which is made to service incoming Http request. Every incoming Http request received by ASP.NET is ultimately processed by an instance of a class that implements HttpHandler. (C# .Net Training Videos)
41. What is HTTP Handler?
Answer: Every request into an ASP.NET application is handled by a specialized component known as an HTTP handler. The HTTP handler is the most important ingredient while handling ASP.NET requests.
Examples: ASP.NET uses different HTTP handlers to serve different file types. For example, the handler for web Page creates the page and control objects, runs your code, and renders the final HTML.
ASP.NET default handlers:
Page Handler (.aspx) – Handles Web pages.
User Control Handler (.ascx) – Handles Web user control pages.
Web Service Handler (.asmx) – Handles Web service pages.
Trace Handler (trace.axd) – Handles trace functionality.
Why we need to create our own HTTP Handler: Sometimes we need to avoid ASP.NET full page processing model, which saves a lot of overheads, as ASP.NET web form model has to go through many steps such as creating web page objects, persisting view state, etc. What we are interested in is to develop some low-level interface that provides access to objects like Request and Response but doesn’t use the full control based web form model discussed above.
Examples: Dynamic image creator – Use the System. Drawing classes to draw and size your own images.
RSS – Create a handler that responds with RSS-formatted XML. This would allow you to add RSS feed capabilities to your sites.
Render a custom image,
Perform an ad hoc database query,
Return some binary data.
All HTTP handlers are defined in the section of a configuration file which is nested in the element.
42. What are the Differences between ASP.NET HttpHandler and HttpModule?
Answer: The user requests for a resource on a web server. The web server examines the file name extension of the requested file and determines which ISAPI extension should handle the request. Then the request is passed to the appropriate ISAPI extension. For example, when a .aspx page is requested it is passed to ASP.NET page handler. Then Application domain is created and after that different ASP.NET objects like Httpcontext, HttpRequest, HttpResponse are created. Then an instance of HttpApplication is created and also instance of any configured modules. One can register different events of HttpApplication class like BeginRequest, AuthenticateRequest, AuthorizeRequest, ProcessRequest, etc.
HTTP Handler: HTTP Handler is the process which runs in response to an HTTP request. So whenever a user requests a file it is processed by the handler based on the extension. So, custom https handlers are created when you need special handling based on the file name extension. Let’s consider an example to create RSS for a site. So, create a handler that generates RSS-formatted XML. Now bind the .rss extension to the custom handler.
HTTP Modules: HTTP Modules are plugged into the life cycle of a request. So when a request is processed it is passed through all the modules in the pipeline of the request. So generally https modules are used for:
Security: For authenticating a request before the request is handled.
Statistics and Logging: Since modules are called for every request they can be used for gathering statistics and for logging information.
Custom header: Since the response can be modified, one can add custom header information to the response.
43. How many languages are supported by .NET at the present time?
Answer: When .NET was introduced the first time, it supports many languages like VB.NET, C#, COBOL, and Perl, etc. At the present time, it supports almost 44 languages.
44. What is the .NET Framework and what are the main components of it?
Answer: .NET Framework facilitates the developer to develop, run and deploy the applications like a console application, window Forms applications, web applications, web services, window services, etc. It also provides an environment to create sharable components to be used in distributed computing architecture.
Main components of the .Net Framework:
Common Language Runtime (CLR)
Dynamic Language Runtime (DLR)
45. What is the relation between Classes and Objects?
Class applies to a type or model of a GROUP of itedot-ms, objects, or concepts.
Object applies to a specific material item or concept, a group of which may comprise a class. (Interview Questions and Answers)
46. What is a Form?
Answer: A form is a representation of any window displayed in your application. Form can be used to create standard, borderless, floating, modal windows.
47. What is the Web.config file in ASP?
Answer: The configuration file is used to manage various settings that define a website. The settings are stored in XML files that are separate from your application code. In this way, you can configure settings independently from your code. Generally, a website contains a single Web.config file stored inside the application root directory. However, there can be many configuration files that manage settings at various levels within an application.
Usage of the configuration file
ASP.NET Configuration system is used to describe the properties and behaviors of various aspects of ASP.NET applications. Configuration files help you to manage the settings related to your website. Each file is an XML file (with the extension .config) that contains a set of configuration elements. Configuration information is stored in XML-based text files.
Benefits of XML-based Configuration files:
ASP.NET Configuration system is extensible and application-specific information can be stored and retrieved easily. It is human readable.
You need not restart the webserver when the settings are changed in the configuration file. ASP.NET automatically detects the changes and applies them to the running ASP.NET application.
You can use any standard text editor or XML parser to create and edit ASP.NET configuration files.
All .NET Interview Questions
.Net Training VideosDuration: 30+ Hours | Version: 6.0
Free Bundle Access
Course Future Updates