Top 50 ASP.NET Interview Question and Answers

Share on facebook
Share on telegram
Share on linkedin
Share on twitter

Top 50 ASP.NET Interview Questions and Answers

ASP.NET Interview Question and Answer
ASP.NET Interview Question and Answer

Q1) What is ASP?

ASP stands for Active Server Pages. It is a server-side technology, a development framework provided by Microsoft to build user-friendly dynamic web pages. The various scripting languages are used to create dynamic web pages.

Q2) What is ASP.NET? State the features?

ASP.NET is a part of the .NET framework developed by Microsoft and used to develop Web Applications, Websites, Web Services, Web Forms, Front end UI’s. The .NET compatible languages like Visual Basic, C# can be used to create ASP.NET applications.

Features of ASP.NET:

  • As we must know the performance of the applications we use. ASP.NET has a high performance.
  • It is a cross-platform, server-side technology, supports different browsers.
  • It uses the languages like C# and VB.NET to develop dynamic web applications.
  • The most promising feature of ASP.NET is it separates the code part (logic) and HTML part.
  • ASP.NET pages are compiled, not interpreted.

Q3) What is the difference between ASP & ASP.NET?

ASP

ASP.NET

  1. ASP is known as classic ASP developed by Microsoft and it is interpreted.

 1. ASP.NET is also developed by Microsoft and it is compiled.

  2. ASP uses scripting language like VBScript, to execute the pages.

 2. ASP.NET uses .NET languages like C#, VB.NET.

  3. It is old but still powerful, used to build dynamic web pages.

 3. ASP.NET is also used to build dynamic web pages.

  4. ASP has all HTML and coding logic mixed.

 4. Whereas, ASP.NET has all the HTML and logic parts separated.

Q4) What are the advantages of ASP.NET?


ASP.NET has the following advantages:

  • It allows the code separation from HTML, which leads to the easy maintenance of the pages.
  • The separation of code from HTML also provides more power and flexibility to web pages.
  • As ASP.NET is a part of the .NET framework, it uses services, class libraries provided by the .NET framework.
  • It supports compiled languages instead of interpreted languages.

Q5) What do you know about validation controls?

In ASP.NET validation controls play a very important role. The validation controls are used for validating user input. Whenever we get input from a user, the input should be validated which ensures that we are not sending wrong data to the application.

There are two types of validation controls, as given below:

  • Client-side Validation
  • Server-side Validation

Q6) State the difference between Client-side and Server-side validation?

Client-side Validation: This validation work at the client-side and uses scripting languages such as VBScript, jQuery, JavaScript.

Server-side Validation: This validation works at the server-side and used programming languages such as C#, VB, F#, etc. It is a secure form of validation and works when you submit or send data to the server. It has the main advantage, if a user somehow passed the client-side validation, he can still handle it in the server-side validation.

Q7) What are the various types of validators we have in ASP.NET?

There are following validators are available in ASP.NET

  • RangeValidator Control
  • RequiredValidator Control
  • RegularExpressionValidator Control
  • CompareValidator Control
  • CustomFieldValidator Control
  • ValidationSummary

Q8) How will you differentiate between ASP.NET Webforms and ASP.NET MVC?

ASP.NET Webforms

ASP.NET MVC

1. Uses the page controller approach i.e.  Every page has its controller.

1. Uses the Front controller approach i.e. common controller for all pages.

2. Web forms are based on functions and have a code-behind page.

2. MVC allows the separation of each concern i.e. Model, View, Controller.

3. The request first comes to the controller and the action then the view will be called.

3. The request first comes to page (i.e. View) then it will go to the code-behind page.

4. It uses the Viewstate to maintain the state of the view.

4. The View does not use ViewState for state management.

Q9) What is a Global.asax file?

The Global.asax file stores all the application-level events, logics, and processing. The file is derived from HttpApplication class.

The Global.asax file contains the following events,

  • Application_Start
  • Application_End
  • Session_Start
  • Session_End
  • Application_Error
  • Application_Disposed

Q10) What are the Web.config and Machine.config files?

Both files consist of the configuration settings of our application. Following are the differences,

Web.config:

  • As the name says, it specifically defines the web related configuration.
  • If the Web.config file is missing some setting in it, it just inherits it from the Machine.config file.
  • It includes the settings for State Management, Memory Management, Data Connection, Error Handling, etc.
  • The Web.config files can be multiple (more than one) in an application.

Machine.config:

  • As the name says, it specifically defines the machine or server-related configuration.
  • We can find this file at “< WinDir >\Microsoft.NET\Framework\< version >\config\machine.config”.
  • It gets installed automatically while installing Visual Studio.NET.
  • The machine config file can only be one in an application.

Q11) What are the various page events in ASP.NET?

The page-level events are stated below,

  • PreInit: This is the first event of a page and it is used for setting the master page values dynamically. Also to set the Theme property dynamically.
  • Init: This event fires after the initialization of each control. To set the control properties, the Init event is used.
  • InitComplete: This event is used for the processing tasks that require all initialization to be complete.
  • PreLoad: This event fires before the view state has been loaded and before the page processing. The event is useful for writing the code after the page initialization.
  • PageLoad: The event is useful for setting the control properties after checking the past back.
  • ControlEvents(Postback): On the occurrence of postback, this event gets called. The event handles some specific control events, such as ButtonClick event, TextChanged event, SelectedIndexChanged, etc.
  • LoadComplete: The event is useful for the tasks that require all other controls on the page to be loaded.
  • PreRender: This event allows final changes to the page or its control. The event takes place before the view state is saved.
  • SaveStateComplete: This event is used when the view state requires to be saved. Any changes to the page or controls during this page will be ignored.
  • Render: Render is not an event it is a method, a method of the page object and its controls. And it renders the client-side HTML, DHTML (Dynamic HTML), and scripts for the browser.
  • Unload: The code cleanup is done during this event.

Q12) Explain the Caching?

Caching can increase the performance as it stores the most frequently used items or data in memory which leads to the faster recovery of data from the cache memory instead of the original location.

Q13) What are the different types of caching?

 We have three different types of caching in ASP.NET,

  • Page Caching (Output Caching)
  • Data Caching also called Partial-Page Output Caching
  • Fragment Caching

Q14) What is IIS?

IIS is the Internet Information services which is one of the most powerful web services. It is developed by Microsoft and as the name suggests it provides Internet-based services to ASP.NET web applications.

Q15) What is the usage of IIS?

IIS makes your computer work as a web server and develops and deploys web applications on the server.

  • To handle all the request and response cycles we use IIS.
  • IIS offers very useful services like SMTP and Frontpage extensions.
  • Where, the SMTP sends emails, and to get the dynamic features of IIS (for example, Form Handler) we use Frontpage extensions.

Q16) State the parent class of all web server control?

System.Web.UI.Control class

Q17) Why we use View state?

Viewstate is a method that is used to store or preserve the values and controls of a page before it gets submitted to the server.

Q18) What are the advantages and disadvantages of Viewstate?

Advantages of Viewstate:

  • It stores the data, so the user does not have to fill in the information (data) again and again.
  • Ensures data security. Stores the data in an encrypted format.
  • Does not require server resources.
  • The properties can easily be enabled or disabled.

Disadvantages of Viewstate:

  • Storing a huge amount of data may lead to slowness in loading the page.
  • The data does not get transferred between the pages.

Q19) Which page events include the Viewstate?

The Init and PageLoad events.

Q20) Why we need Viewstate?

The reason we need ViewState in our applications is:

If while the submission user gets a validation error or the user may refresh the page after entering so much information on the page. The information filled by a user gets lost and the user now needs to start filling the information again. To reduce such chances we use Viewstate in ASP.NET. Viewstate stores or preserves the data filled by a user in a very secure manner.

Q21) What is MVC?

MVC is a design pattern that uses three different components like Model-View-Controller. It is a pattern we use which separates an application into three different components which are stated below,

  • Model (It represents as data)
  • View (It represents as presentation)
  • Controller (It acts as an interface between Model and View)

This also means that MVC helps us to keep the application logic from UI separated.

Q22) What is the ASP.NET MVC framework?

The ASP.NET MVC framework used to create web applications based on the Model-View-Controller design pattern. It is a lightweight framework that provides full control to HTML, JavaScript, and CSS. To define this we use System.Web.MVC assembly.

Q23) List the advantages and disadvantages of ASP.NET MVC?

Advantages:

  • The main advantage of using MVC is that as separates the components into Model, View, and Control, it allows easy maintenance of our application.
  • It gives the flexibility to the developers to work on different components at the same time.
  • Useful when working on large applications.

Disadvantages:

  • The understanding of the flow is difficult and complex.
  • Not useful to work on small-level applications.
  • The deployment is a little bit hard.

Q24) Describe the concepts of Globalization and Localization in ASP.NET?

Globalization: It is a process of designing the application in a way so that it can be used by users across the globe.

Localization: It is a process to make the application behave as per the current culture and locale.

Q25) What is the way to display validation messages in one control?

The ValidationSummary control is used to display all the validation messages in one control.

Q26) How will you explain cookies in ASP.NET?

Cookies are used to store user-specific information and it gets displayed when the user requests for a page when the user last visited the page etc. Cookies are used to improve the user experience and faster page loading.

Q27) What are the different types of cookies?

In ASP.NET there are following two types of cookies,

  • Session Cookie
  • Persistent Cookie

Q28) Why we use the “isPostBack” property?

To check the status of a page (i.e. the page is posted back or not), we use isPostBack property.

Q29) State the difference between Early Binding and Late Binding?

Early Binding: In early binding, which method(non-virtual) to call is decided at compile time.

Late Binding: In late binding, which method(virtual) to call is decided at run time.

Q30) How do you explain the Web Services in ASP.NET?

Web services are software programs that use XML to exchange data with other software programs via some common internet protocols. Web services are very useful for communication over the internet.

Q31) What are the features of web services?

Features:

  • Platform Independent
  • Language-Independent
  • Protocol Independent
  • Scalable
  • XML based
  • Programmable

Q32) How will you add an event handler?

By using the attributes property we can add an event handler, as given below:

Example:

btnSubmit.Attributes.Add(“onClick”,”onMouseClick”, “JavascriptCode()”);

Q33) Can you run a web application without the web.config file?

Yes, we can run an application without web.config file.

Q34) What do you know about ASP.NET Webforms?

Web forms are web pages built on ASP.NET technology. In Visual Studio we can create ASP.NET Webforms. The execution of these web pages is done on the server and it displays output to the browser. The web forms are made of two components the visual representation i.e. the ASPX file and the code behind the form.

Q35) What does mean by Authentication and Authorization in ASP.NET?

Authentication means to identify the user by their credentials that he is the validated person or not.

Authorization means allowing the authenticated user to access the particular resources.

Q36) What are the different types of Authentication available in ASP.NET?

Below are the types of authentication:

  • Forms authentication: This authentication process need some built-in windows security features to authenticate a user.
  • Windows authentication: This authentication process needs the data from the database.
  • Passport authentication: Needs validation against a centralized authentication service (Passport service).

Q37) Which method is used to run the validation controls?

The page.validate() method is used to run validation controls.

Q38) State the different types of cookies in ASP.NET?

Persistent Cookie: This cookie resides in the user’s machine for some period of time like for 10 days, one month, and never.

Session Cookie: As its name says. It stays for a session only on the client machine till the user logoff.

Q39) What do you know about ASP.NET Core?

ASP.NET Core is a free, cross-platform, and open-source design framework that is used for developing modern, well-advanced, cloud-based web applications.

Q40) How will you differ ASP.NET Core from ASP.NET?

  • NET Core is a modern, well-advanced design framework than the ASP.NET.
  • It is easy to develop cross-platform web applications in ASP.NET Core on Windows, Mac, and Linux.
  • Both are runtime frameworks.
  • NET Core is lightweight and allows faster development.
  • It is easy to maintain.
  • It supports to NuGet Package Manager.

Q41) How to specify a ConnectionString in a web.config file?

The connection string can be added as follows:

				
					<configuration>
<connectionStrings>
<add name=”yourconnectionstringName” connectionString=”Data Source= DatabaseServerName; Integrated Security=true; Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; “providerName=”System.Data.SqlClient”/>
</connectionStrings>
</configuration>

				
			

Q42) How do you explain about ASP.NET web API framework?

The ASP.NET Web API is a framework used for developing HTTP-based services. Such services can be accessed from different platforms like web, mobile, windows, etc.

Q43) Why do we need Web API?

Using Web API you can access all the HTTP-based services like requests, responses, URIs, caching, etc. Also, the web APIs are lightweight in nature which leads reaching to a broader range of clients. Web APIs are easier and faster than the WCF (Windows Communication Foundation) in creating services.

Q44) Explain the workflow of a request in ASP.NET MVC?

The request flow from clients to the server is as follows:

  • The coming request from the client is being passed to the controller.
  • The controller performs some actions and processes the request and also creates a Data Model for that particular request.
  • The view creates a frontend design for the created data model.
  • The view then transforms the received Data Model into an appropriate output format.
  • The output format is now available to the user which is rendered on the browser.

Q45) What are Server controls in ASP.NET?

Server controls play a very useful role in developing web applications. Below are the four different types of server controls we have in ASP.NET,

  • HTML Server controls
  • Web Server controls
  • Validation controls
  • User controls

Q46) Describe the HTML server controls in ASP.NET?

HTML server controls are the standard HTML controls that enable server-side processing. These have the attribute “runat=server”. HTML server controls have the same properties and output as the HTML tags and it provides automatic server-side events and state management.

Q47) Specify the available session states in ASP.NET?

There are following 5 types of session modes are available in ASP.NET which are as follows:

  • Inproc: This is a default state and it stores the session in memory on the webserver.
  • StateServer: Stores session in a separate process called ASP.NET state service.
  • SQLServer: It stores sessions in a SQL server database.
  • Custom: It enables a custom storage provider.
  • Off: Disables a session state.

Q48) What are the different techniques of navigation in ASP.NET?

Navigating a page means redirecting or moving from one page to another on a website. ASP.NET has different ways to navigate a page, which are given below:

  • Redirect
  • Transfer
  • Execute
  • Cross page posting

Q49) What are the Security Controls we use in ASP.NET?

< asp:Login >: Allows users to enter their credentials.

< asp:LoginName >: Displays the name of logged user.

< asp:LoginStatus >: Display the status of the user that he is authenticated or not.

< asp:LoginView >: Displays various login views according to the template.

< asp:PasswordRecovery >: It is used to recover the lost password by sending an email.

Q50) How will you create a theme in the ASP.NET application?

				
					<configuration>
<system.web>
<pages theme=”Windows10”/>
</system.web>
</configuration> 

				
			

Table of Contents