Corporate Training
Request Demo
Click me
Let's Talk
Request Demo

ASP.NET Interview Questions and Answers

by Venkatesan M, on Nov 6, 2017 3:44:12 PM

ASP.NET Interview Questions and Answers

Q1. What is ASP?

Ans: Active Server Pages (ASP), also known as Classic ASP, is a Microsoft's server-side technology, which helps in creating dynamic and user-friendly Web pages. It uses different scripting languages to create dynamic Web pages, which can be run on any type of browser. The Web pages are built by using either VBScript or JavaScript and these Web pages have access to the same services as Windows application, including ADO (ActiveX Data Objects) for database access, SMTP (Simple Mail Transfer Protocol) for e-mail, and the entire COM (Component Object Model) structure used in the Windows environment. ASP is implemented through a dynamic-link library (asp.dll) that is called by the IIS server when a Web page is requested from the server.

Q2. What is ASP.NET?

Ans: ASP.NET is a specification developed by Microsoft to create dynamic Web applications, Web sites, and Web services. It is a part of .NET Framework. You can create ASP.NET applications in most of the .NET compatible languages, such as Visual Basic, C#, and J#. The ASP.NET compiles the Web pages and provides much better performance than scripting languages, such as VBScript. The Web Forms support to create powerful forms-based Web pages. You can use ASP.NET Web server controls to create interactive Web applications. With the help of Web server controls, you can easily create a Web application.


What is ASP.NET?

Ans: ASP.NET was developed in direct response to the problems that developers had with classic ASP. Since ASP is in such wide use, however, Microsoft ensured that ASP scripts execute without modification on a machine with the .NET Framework (the ASP engine, ASP.DLL, is not modified when installing the .NET Framework). Thus, IIS can house both ASP and ASP.NET scripts on the same machine.

Q3. What Are Advantages of ASP.NET?

Ans: Advantages of are:

Separation of Code from HTML: 

To make a clean sweep, with ASP.NET you have the ability to completely separate layout and business logic. This makes it much easier for teams of programmers and designers to collaborate efficiently.
Support for compiled languages:

Developer can use VB.NET and access features such as strong typing and object-oriented programming. Using compiled languages also means that ASP.NET pages do not suffer the performance penalties associated with interpreted code. ASP.NET pages are precompiled to byte-code and Just In Time (JIT) compiled when first requested. Subsequent requests are directed to the fully compiled code, which is cached until the source changes.
Use services provided by the .NET Framework:

The .NET Framework provides class libraries that can be used by your application. Some of the key classes help you with input/output, access to operating system services, data access, or even debugging. We will go into more detail on some of them in this module.
Graphical Development Environment:

Visual Studio .NET provides a very rich development environment for web developers. You can drag and drop controls and set properties the way you do in Visual Basic 6. And you have full IntelliSense support, not only for your code, but also for HTML and XML.
State management:

To refer to the problems mentioned before, ASP.NET provides solutions for session and application state management. State information can, for example, be kept in memory or stored in a database. It can be shared across web farms, and state information can be recovered, even if the server fails or the connection breaks down.
Update files while the server is running:

Components of your application can be updated while the server is online and clients are connected. The framework will use the new files as soon as they are copied to the application. Removed or old files that are still in use are kept in memory until the clients have finished.
XML-Based Configuration Files:

Configuration settings in ASP.NET are stored in XML files that you can easily read and edit. You can also easily copy these to another server, along with the other files that comprise your application.


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 Web Forms. 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

Q4. What is the basic difference between ASP and ASP.NET?

Ans: The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses VBScript; therefore, when an ASP page is executed, it is interpreted. On the other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).

Q5. In which event are the controls fully loaded?

Ans: Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event

[teaserbox type="5" img="2802" title="Interested in learning" subtitle="Join Us Today! We are myTectra!" link_url="" target="blank"]

Q6. How can we identify that the Page is Post Back?

Ans: Page object has an "IsPostBack" property, which can be checked to know that is the page posted back.

Q7. What is the lifespan for items stored in ViewState?

Ans: The items stored in ViewState live until the lifetime of the current page expires including the postbacks to the same page.

Q8. How information about the user's locale can be accessed?

Ans: The information regarding a user's locale can be accessed by using the System.Web.UI.Page.Cultureproperty.

Q9. What is the difference between SQL notification and SQL invalidation?

Ans: The SQL cache notification generates notifications when the data of a database changes, on which your cache item depends. The SQL cache invalidation makes a cached item invalid when the data stored in a SQL server database changes.

Q10. Which is the parent class of the Web server control?

Ans: The System.Web.UI.Control class is the parent class for all Web server controls.

Q11. What are the different validators in ASP.NET?

Ans: ASP.NET validation controls define an important role in validating the user input data. Whenever the user gives the input, it must always be validated before sending it across to various layers of an application. If we get the user input with validation, then chances are that we are sending the wrong data. So, validation is a good idea to do whenever we are taking input from the user.There are the following two types of validation in ASP.NET:

Client-Side Validation

Server-Side Validation

Client-Side Validation:

When validation is done on the client browser, then it is known as Client-Side Validation. We use JavaScript to do the Client-Side Validation.

Server-Side Validation:

When validation occurs on the server, then it is known as Server-Side Validation. Server-Side Validation is a secure form of validation. The main advantage of Server-Side Validation is if the user somehow bypasses the Client-Side Validation, we can still catch the problem on server-side.

The following are the Validation Controls in ASP.NET:

RequiredFieldValidator Control

CompareValidator Control

RangeValidator Control

RegularExpressionValidator Control

CustomFieldValidator Control


Q12. Can you set which type of comparison you want to perform by the CompareValidator control?

Ans: Yes, by setting the Operator property of the CompareValidator control.

Q13. What is the behavior of a Web browser when it receives an invalid element?

Ans: The behavior of a Web browser when it receives an invalid element depends on the browser that you use to browse your application. Most of the browsers ignore the invalid element; whereas, some of them display the invalid elements on the page.

Q14. What are the advantages of the code-behind feature?

Ans: The code-behind feature of ASP.NET offers a number of advantages:

Makes code easy to understand and debug by separating application logic from HTML tags

Provides the isolation of effort between graphic designers and software engineers

Removes the problems of browser incompatibility by providing code files to exist on the Web server and supporting Web pages to be compiled on demand.

Q15. How do you sign out from forms authentication?

Ans: The FormsAuthentication.Signout() method is used to sign out from the forms authentication.

Q16. What is AutoPostBack?

Ans: If you want a control to postback automatically when an event is raised, you need to set the AutoPostBackproperty of the control to True.

Q17. What is View State?

Ans: View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.A web application is stateless. That means that a new instance of a page is created every time when we make a request to the server to get the page and after the round trip our page has been lost immediately

Features of View State

These are the main features of view state:

Retains the value of the Control after post-back without using a session.

Stores the value of Pages and Control Properties defined in the page.

Creates a custom View State Provider that lets you store View State Information in a SQL Server Database or in another data store.

Q18. What Are Advantages of View State?

Ans: Advantages of view state are:Easy to Implement. No server resources are required: The View State is contained in a structure within the page load. Enhanced security features: It can be encoded and compressed or Unicode implementation.

Q19. What is the function of the ViewState property?

Ans: The ASP.NET 4.0 introduced a new property called ViewStateMode for the Control class. Now you can enable the view state to an individual control even if the view state for an ASP.NET page is disabled.

Q20. Why do you use the App_Code folder in ASP.NET?

Ans: The App_Code folder is automatically present in the project. It stores the files, such as classes, typed data set, text files, and reports. If this folder is not available in the application, you can add this folder. One of the important features of the App_Code folder is that only one dll is created for the complete folder, irrespective of how many files it contains.

Q21. Define a multilingual Web site.

Ans: A multilingual Web site serves content in a number of languages. It contains multiple copies for its content and other resources, such as date and time, in different languages.

Q22. What is an ASP.NET Web Form?

Ans: ASP.NET Web forms are designed to use controls and features that are almost as powerful as the ones used with Windows forms, and so they are called as Web forms. The Web form uses a server-side object model that allows you to create functional controls, which are executed on the server and are rendered as HTML on the client. The attribute, runat="server", associated with a server control indicates that the Web form must be processed on the server.

Q23. What is the difference between a default skin and a named skin?

Ans: The default skin is applied to all the Web server controls in a Web form, which are of similar type, and it does not provide a Skin ID attribute. The named skin provides a Skin ID attribute and users have to set the Skin ID property to apply it.

Q24. What are the data controls available in ASP.NET?

Ans: The Controls having DataSource Property are called Data Controls in ASP.NET. ASP.NET allows powerful feature of data binding, you can bind any server control to simple properties, collections, expressions and/or methods. When you use data binding, you have more flexibility when you use data from a database or other means.

Data Bind controls are container controls.

Controls -> Child Control

Data Binding is binding controls to data from databases. With data binding we can bind a control to a particular column in a table from the database or we can bind the whole table to the data grid.

Data binding provides simple, convenient, and powerful way to create a read/write link between the controls on a form and the data in their application.

Data binding allows you to take the results of properties, collection, method calls, and database queries and integrate them with your ASP.NET code. You can combine data binding with Web control rendering to relieve much of the programming burden surrounding Web control creation. You can also use data binding with ADO.NET and Web controls to populate control contents from SQL select statements or stored procedures.

Data binding uses a special syntax:

<%# %>

The <%#, which instructs ASP.NET to evaluate the expression. The difference between a data binding tags and a regular code insertion tags <% and %> becomes apparent when the expression is evaluated. Expressions within the data binding tags are evaluated only when the DataBind method in the Page objects or Web control is called.

Data Bind Control can display data in connected and disconnected model.

Following are data bind controls in ASP.NET:

Repeater Control

DataGrid Control

DataList Control

GridView Control







BulletList etc.

Q25. What is IIS? Why is it used?

Ans: Internet Information Services (IIS) is created by Microsoft to provide Internet-based services to ASP.NET Web applications. It makes your computer to work as a Web server and provides the functionality to develop and deploy Web applications on the server. IIS handles the request and response cycle on the Web server. It also offers the services of SMTP and FrontPage server extensions. The SMTP is used to send emails and use FrontPage server extensions to get the dynamic features of IIS, such as form handler.

Q26. What is Query String? What are its advantages and limitations?

Ans: The Query String helps in sending the page information to the server.

The Query String has the following advantages:

Every browser works with Query Strings.

It does not require server resources and so does not exert any kind of burden on the server.
The following are the limitations of Query String:

Information must be within the limit because URL does not support many characters.

Information is clearly visible to the user, which leads to security threats.

Q27. What is actually returned from server to the browser when a browser requests an .aspx file and the file is displayed?

Ans: When a browser requests an .aspx file then the server returns a response, which is rendered into a HTML string.

Q28. How can you display all validation messages in one control?

Ans: The ValidationSummary control displays all validation messages in one control.

Q29. Which two new properties are added in ASP.NET 4.0 Page class?

Ans: The two new properties added in the Page class are MetaKeyword and MetaDescription.

Q30. What is tracing? Where is it used?

Ans: Tracing displays the details about how the code was executed. It refers to collecting information about the application while it is running. Tracing information can help you to troubleshoot an application. It enables you to record information in various log files about the errors that might occur at run time. You can analyze these log files to find the cause of the errors.

In .NET, we have objects called Trace Listeners. A listener is an object that gets the trace output and stores it to different places, such as a window, a file on your locale drive, or a SQL Server.

The System.Diagnostics namespace contains the predefined interfaces, classes, and structures that are used for tracing. It supplies two classes, Trace and Debug, which allow you to write errors and logs related to the application execution. Trace listeners are objects that collect the output of tracing processes.


Tracing helps to see the information of issues at the runtime of the application. By default Tracing is disabled.

Tracing has the following important features:

We can see the execution path of the page and application using the debug statement.

We can access and manipulate trace messages programmatically.

We can see the most recent tracing of the data.

Tracing can be done with the following 2 types.

Page Level: When the trace output is displayed on the page and for the page-level tracing we need to set the property of tracing at the page level.

<%@ Page Trace="true" Language="C#" 

Application: Level: In Application-Level tracing the information is stored for each request of the application. The default number of requests to store is 10. But if you want to increase the number of requests and discard the older request and display a recent request then you need to set the property in the web.config file.

<trace enabled="true"/>

Q31. What is the difference between authentication and authorization?

Ans: Authentication verifies the identity of a user and authorization is a process where you can check whether or not the identity has access rights to the system. In other words, you can say that authentication is a procedure of getting some credentials from the users and verify the user's identity against those credentials. Authorization is a procedure of granting access of particular resources to an authenticated user. You should note that authentication always takes place before authorization.

Q32. What is the authentication and authorization in ASP.NET?

Ans: Authentication: Prove genuineness

Authorization: process of granting approval or permission on resources.

In ASP.NET authentication means to identify the user or in other words its 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.

Q33. What are the types of authentication and authorization in ASP.NET
Types of authentication and authorization in ASP.NET:

Ans: There are four ways of doing authentication and authorization in ASP.NET:

  1. Windows authentication: In this methodology ASP.NET web pages will use local windows users and groups to authenticate and authorize resources.
  2. 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.
  3. Passport authentication: Passport authentication is based on the passport website provided by the 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.
  4. 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.

<authentication mode="Windows"/>

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.


<deny users="?"/>


Q34. How can you register a custom server control to a Web page?

Ans: You can register a custom server control to a Web page using the @Register directive.

Q35. Which ASP.NET objects encapsulate the state of the client and the browser?

Ans: The Session object encapsulates the state of the client and browser.

Differentiate globalization and localization.

The globalization is a technique to identify the specific part of a Web application that is different for different languages and make separate that portion from the core of the Web application. The localization is a procedure of configuring a Web application to be supported for a specific language or locale.

Q36. What is ViewState?

Ans: The ViewState is a feature used by ASP.NET Web page to store the value of a page and its controls just before posting the page. Once the page is posted, the first task by the page processing is to restore the ViewState to get the values of the controls.

Q37. Which method is used to force all the validation controls to run?

Ans: The Page.Validate() method is used to force all the validation controls to run and to perform validation.

Q38. Which method has been introduced in ASP.NET 4.0 to redirect a page permanently?

Ans: The RedirectPermanent() method added in ASP.NET 4.0 to redirect a page permanently. The following code snippet is an example of the RedirectPermanent() method:

Q39. How can you send an email message from an ASP.NET Web page?

Ans:Youcan use the System.Net.Mail.MailMessage and the System.Net.Mail.SmtpMail classes to send an email in your Web pages. In order to send an email through your mail server, you need to create an object of the SmtpClient class and set the server name, port, and credentials.

Q40. What is the difference between the Response.Write() and Response.Output.Write() methods?

Ans: The Response.Write() method allows you to write the normal output; whereas, the Response.Output.Write() method allows you to write the formatted output.

Q41. What does the Orientation property do in a Menu control?

Ans: Orientation property of the Menu control sets the horizontal or vertical display of a menu on a Web page. By default, the orientation is vertical.

Q42. Differentiate between client-side and server-side validations in Web pages.

Ans: Client-side validations take place at the client end with the help of JavaScript and VBScript before the Web page is sent to the server. On the other hand, server-side validations take place at the server end.

Q43. How does a content page differ from a master page?

Ans: A content page does not have complete HTML source code; whereas a master page has complete HTML source code inside its source file.

Q44. Suppose you want an ASP.NET function (client side) executed on the MouseOver event of a button. Where do you add an event handler?

Ans: The event handler is added to the Add() method of the Attributes property.

Q45. What is the default timeout for a Cookie?

Ans: The default time duration for a Cookie is 30 minutes.

Q46. What are HTTP handlers in ASP.NET?

Ans: HTTP handlers, as the name suggests, are used to handle user requests for Web application resources. They are the backbone of the request-response model of Web applications. There is a specific event handler to handle the request for each user request type and send back the corresponding response object.

Each user requests to the IIS Web server flows through the HTTP pipeline, which refers to a series of components (HTTP modules and HTTP handlers) to process the request. HTTP modules act as filters to process the request as it passes through the HTTP pipeline. The request, after passing through the HTTP modules, is assigned to an HTTP handler that determines the response of the server to the user request. The response then passes through the HTTP modules once again and is then sent back to the user.

You can define HTTP handlers in the <httpHandlers> element of a configuration file. The <add> element tag is used to add new handlers and the <remove> element tag is used to remove existing handlers. To create an HTTP handler, you need to define a class that implements the IHttpHandler interface.

Q47. What are the events that happen when a client requests an ASP.NET page from IIS server?

Ans: The following events happen when a client requests an ASP.NET page from the IIS server:

User requests for an application resource.

The integrated request-processing pipeline receives the first user request.

Response objects are created for each user request.

An object of the HttpApplication class is created and allocated to the Request object.

The HttpApplication class processes the user request.

Q48. Explain file-based dependency and key-based dependency.

Ans: In file-based dependency, you have to depend on a file that is saved in a disk. In key-based dependency, you have to depend on another cached item.

Q49. How can you implement the postback property of an ASP.NET control?

Ans: You need to set the AutoPostBack property to True to implement the PostBack property of controls.

Q50. Explain how Cookies work. Give an example of Cookie abuse.

Ans: The server tells the browser to put some files in a cookie, and the client then sends all the cookies for the domain in each request. An example of cookie abuse is large cookies affecting the network traffic.

Q51. What are Cookies in ASP.NET?

Ans: Cookies are a State Management Technique that can store the values of control after a post-back. Cookies can store user-specific Information on the client's machine like when the user last visited your site. Cookies are also known by many names, such as HTTP Cookies, Browser Cookies, Web Cookies, Session Cookies and so on. Basically cookies are a small text file sent by the web server and saved by the Web Browser on the client's machine.List of properties containing the HttpCookies Class:

Domain: Using these properties we can set the domain of the cookie.

Expires: This property sets the Expiration time of the cookies.

HasKeys: If the cookies have a subkey then it returns True.

Name: Contains the name of the Key.

Path: Contains the Virtual Path to be submitted with the Cookies.

Secured: If the cookies are to be passed in a secure connection then it only returns True.

Value: Contains the value of the cookies.

Limitation of the Cookies

The size of cookies is limited to 4096 bytes.

A total of 20 cookies can be used in a single website.

Q52. Explain login controls.

Ans: Login controls are built-in controls in ASP.Net for providing a login solution to ASP.NET application. The login controls use the membership system to authenticate a user credentials for a Web site.

There are many controls in login controls.

ChangePassword control - Allows users to change their password.

CreateUserWizard control - Provides an interface to the user to register for that Web site.

Login control - Provides an interface for user authentication. It consists of a set of controls, such as TextBox, Label, Button, CheckBox, HyperLink.

LoginView control - Displays appropriate information to different users according to the user's status.

LoginStatus control - Shows a login link to users, who are not authenticated and logout link, who are authenticated

LoginName control - Displays a user name, if the user logs in.

PasswordRecovery control - Allows users to get back the password through an e-mail, if they forget.

Q53. Use of CheckBox in .NET?

Ans: 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.

Property Description
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 check box 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.
runat Specifies that the control is a server control. Must be set to "server".
Text The text next to the check box.
TextAlign On which side of the check box 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.


Q54. What is the use of PlaceHolder control? Can we see it at runtime?

Ans: The PlaceHolder control acts as a container for those controls that are dynamically generated at runtime. We cannot see it at runtime because it does not produce any visible output. It used only as a container.

Q55. What setting must be added in the configuration file to deny a particular user from accessing the secured resources?

Ans: To deny a particular user form accessing the secured resources, the web.config file must contain the following code:

<authorization >
<deny users="username" />

Q56. What are the event handlers that can be included in the Global.asax file?

Ans: The Global.asax file contains some of the following important event handlers:







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:







Q57. What is caching in ASP.NET?

Ans: Caching is one of the most interesting concept 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, 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”.

What are Types of caching?

Types of Caching are:

Page caching

Fragment caching

Data caching

Q58. What is the difference between page-level caching and fragment caching?

Ans: In the page-level caching, an entire Web page is cached; whereas, in the fragment caching, a part of the Web page, such as a user control added to the Web page, is cached.

Q59. Make a list of all templates of the Repeater control.

Ans: The Repeater control contains the following templates:






Q60. What is MVC?

Ans: Model-View-Controller (MVC) is a pattern to separate an application into the following three main components:




The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating web applications. The ASP.NET MVC Framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentications. The MVC framework is defined in the System.Web.Mvc assembly. It provides full control over HTML, JavaScript and CSS. It's the better as well as a recommended approach for large-scale applications where various teams are working together.

Q61. What are the advantages of The ASP.NET MVC framework?

Ans: The ASP.NET MVC framework offers the following advantages:

It makes it very easy to manage complexity by dividing an application into the Model, View and Controller.

It does not use view state or server-based forms.

Full control over HTML, JavaScript and CSS.

It provides better support for Test-Driven Development (TDD).

It works well for Web applications that are supported by large teams of developers and for web designers who need a high degree of control over the application behaviour.

By default support of Facebook and Google Authentication.

It easy to manage a large application to divide in multiple areas.

Related Interview Questions...

ASP.Net Web API Essentials using C# Interview Questions

VB.NET Interview Questions and Answers

ASP.NET MVC Interview Questions and Answers

ASP.NET Interview Questions and Answers For Experienced

.Net Interview Questions and Answers

.NET Apps Interview Questions

Topics:Asp.Net Interview Questions and AnswersInformation Technologies (IT)



Top Courses in Python

Top Courses in Python

We help you to choose the right Python career Path at myTectra. Here are the top courses in Python one can select. Learn More →

aathirai cut mango pickle