Register Login

ASP.NET Interview Questions

1. What is ASP.NET?

ASP.NET is a server-side open-source platform developed by Microsoft that is used for developing dynamic web pages and web applications for mobile devices and PCs. ASP.NET is a part of the Microsoft.Net platform and can work along with the HTTP protocol.

2. What are the advantages of ASP.NET?

ASP.NET provides developers with several advantages:

  • Separation of HTML and code: The layout of the page and the code for the page can be handled separately, allowing designers and programmers to collaborate with greater ease.
  • Supports compiled languages: Support for compiled languages ensure that programs run better and faster.
  • The .NET Framework: Microsoft provides the .NET framework containing class libraries that can be accessed by the program, making the coding process much simpler.
  • Graphical development: The development environment for ASP.NET is a rich GUI form, allowing programmers to work easily with features like drag and drop, property settings, etc. all on a visible interface apart from the codes.
  • State management: Session and application State Management solutions are given by the ASP.NET system. The State information can be stored in memory or in a database, can be shared and recovered if the server fails.
  • File updating in running server: ASP.NET allows parts of the application to be updated even with the server running and clients connected.
  • XML configuration files: Configuration settings of ASP.NET are stored as XML files which are easy to work with.

3. What is ASP and what does ASP stand for?

The ASP framework stands for Active Server Pages, it is a server-side technology where the code is executed by the server. If a web browser makes a request for an ASP file, the file is read via ASP engine and the code is executed. After execution, the result is returned to the browser.

4. What is PostBack in ASP.NET?

Using the PostBack process, an ASP.NET page can be submitted to the server. This process is used when some credentials in the page like passwords and usernames have to be verified against the original credentials.

This method is performed when the client system is not able to do it and the credentials have to be sent back to the server.

5. What is ViewState in ASP.NET?

The ViewState is a state management technique that is used for storing the user information of the page during the PostBack process. The ViewState holds the values of the controls but does not restore value to this control after the postback process is finished. This feature is switched on by default even if the page is not used in a postback.

6. What are Cookies in ASP.NET?

A cookie in ASP.NET is used for storing user information that can be read by the web application if the user visits the site again. If a request for a website is made, then the server responds by sending a cookie file along with the site. They increase search efficiency.

7. How to connect database in ASP.NET?

Database connection in ASP.NET can be done in two ways. A data source control is concerned with connecting to the database, selecting the data and caching data. The data view control is used for data manipulation and displaying data. A connection to a database server is also possible by implementing C# code.

8. What is master page in ASP.NET?

A master page is a file having a .master extension that is used for containing HTML, server controls and static text. It provides the placeholders for storing content and templates for forms. If a request for a website made, the layout inside the master's page is combined with content to produce the result.

9. How to bind drop-down list and Grid View in ASP.NET?

Steps to bind Drop-Downlist and Gridview in ASP.NET are:

  • Create a blank website in Visual Studio.
  • Add the web form and the SQL database.
  • Add a table to the database.
  • Modify the gridview_demo.aspx file to have a table with a drop-down
  • Write the code in the gridview_demo.aspx.cs to bind the drop-down list to the grid view.

10. How to add background image in ASP.NET?

The steps to add background image in asp.net are:

  • Include a CSS file in the HTML document for the ASP page or form.
  • Inside the CSS file add the background image by using the following code:
body{ background-image:URL('images/background.png'); } where the background.png is an example of an image that can be used.

11. What is query string in ASP.NET?

An ASP.NET QueryString is a set of characters that are provided to a web browser. It is used when values need to be transferred from one page to another. A QueryString collection is used to store and obtain values of variables in an HTTP query string. A QueryString for HTTP consists of the user search queries followed by a question mark.

12. What is caching in ASP.NET?

Caching is the method of storing frequently used information in the memory so that if that data is needed in future the cache can be accessed to obtain it. At that time the application does not have to generate the data. It improves the performance of the ASP.NET pages as they are dynamically created here.

13. How to send a variable between pages in ASP.NET?

Variables can be sent between pages in asp.net by the following ways:

  1. Using a QueryString: by utilizing a web form that has buttons for passing the values to another page.
  2. Use Session Variables: through a web form that has been set to control values which are accessible in the other form
  3. By the Server.Transfer method
  4. By Web cache
  5. Using Cookies
  6. Form posting

14. What is Databinding in ASP.NET?

The DataBind method is inherited by every ASP.NET webform from the Control class, that gives it the functionality to bind data along with its properties. It is called simple data binding that attaches a collection that implements IEnumerable interface to any control’s DataSource property.

15. How to add Bootstrap in ASP.NET?

The steps to add bootstrap in ASP.NET are:

  • Create an empty WebForms project in ASP.NET.
  • Download the compiled version of Bootstrap and unzip the files.
  • Copy the CSS and JS folders and place them inside the ASP.NET projects folder.
  • In the Visual Studio solution explorer and include the CSS and JS folders in the project.
  • Similarly, download and include the jQuery folders in the project.

16. What is a Crystal Report in ASP.NET?

Crystal reports in ASP.NET are applications that can create reports from different data sources like XML files and databases. These reports can be used to represent charts, totals and complex reports in other programming languages. The Visual Studio IDE comes with integrated Crystal reports.

17. What is AutoEventWireup in ASP.NET?

The AutoEventWireup is an attribute of the page directive. If it is set to true then the page framework invokes the events of the page directly. It is a Boolean value that depicts whether the page events are autowired. The default value is true.

18. How to use repeater in ASP.NET?

The Repeater control is a data-bind control that represents a list of items that are control bound. This control may be bound to a database, XML file or some other list of items.

The steps to use a Repeater are:

  • Prepare a website named Repeater Control.
  • Inside the web.config file put the code below
<connectionStrings><add name="constr" connectionString="initial catalog=puran; data source=MCN002; integrated security=sspi"/></connectionStrings>

19. How to convert HTML to ASP.NET?

To convert an HTML page to an ASP.NET page the contents of the HTML has to be pasted inside the body of the ASPX page. The content of the head section has to be pasted inside the ASPX head section.

The CSS has to be included within a folder inside the ASP project. The <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> has to be added at the top also.

20. What is security, authentication, and authorization in ASP.NET?

Authentication in ASP.NET is the process of verifying user credentials and authorization is allowing these users to access the resources. Security is the umbrella under which the two actions are performed.

21. Explain role-based security in ASP.NET

Role-based security is the concept of partitioning the website based on user roles. The user will get access to the resources based on their roles like administrator or guest. It is used when an application needs approval from multiple sources to work.

22. What is Validation in ASP.NET?

Validation is a system of checking the user inputs before they are layered into the application to ensure wrong data compromising the working of the application is not sent.

23. What is client-side validation?

Validation performed on the client browser using JavaScript is called client-side validation.

24. What is server-side validation?

Validation done at the server is called server-side validation. It is a more secure check than the user side where errors are caught even if the user has bypassed client-side validation.

25. What is meant by View State?

View State is a Page-Level State Management procedure that preserves the Value of a Page and Control properties during round trips, that is sending a request to server and return of page from the server.

26. What is meant by Caching in ASP.NET?

Caching is the process where the output that a page generates is stored in memory, and the saved output or cache allows the page being loaded faster the next time with only the required modifications being applied.

28. What is meant by MVC in ASP.NET?

MVC or Model View Controller is a pattern of separating a complete application into three components: Model, View, and Controller. The ASP.NET MVC Framework is a very testable and lightweight presentation framework integrated with ASP.NET features providing complete control over JavaScript, CSS, and HTML, and is better used in applications of a large scale with multiple teams working together.

29. What various Session State Management choices does ASP.NET provide?

Session states may be managed in ASP.NET in two ways:

  • In Process: The Session data is stored in the web server memory.
  • Out of Process: The Session data is stored in an external server which may be an SQL or State Server.

30. What do Cookies do in ASP.NET?

Cookies are small files sent from the server which are saved in the client’s computer by the browser. They are a State Management technique to store user-specific information on the user’s system, enhancing webpage performance.

31. How are web config and machine config different?

A: Web config file is specific to the web application, while the machine config is specific to the machine or the server. Thus, there may be many web config files for an application, but only a single machine config file for each server.

32. What is meant by Role-Based Security?

A: Role-Based Security is a system for allowing access to specific parts of the application to specific user groups only. Thus an Administrator has greater access than a User, who in turn has greater access than a Guest.

33. What is meant by Cross Page Posting?

Data is normally posted to the same page when the submit button is clicked on a webpage. Cross Page Posting is the method where the data is submitted to a different page when the submit button is clicked on a webpage.

34. What are boxing and unboxing in ASP.NET?

Boxing is the assignment of a value type variable to a reference type variable, while unboxing is the exact opposite, assignment of a reference type variable to a value type variable.

35. What is the difference between strong typing and weak typing?

Strong Typing of the code means the variable data types are checked during compilation hence errors are avoided during runtime. Weak Typing of code checks the data types during runtime itself and hence can cause issues during runtime.

36. What cookies are used in ASP.NET?

Two types of cookies are used:

  • Session Cookie: Stays in the user’s system for a single session till the user logs out.
  • Persistent Cookie: Has a specific lifespan and exists in the user’s system for that time.

37. What is the role of AJAX in ASP.NET?

AJAX or Asynchronous JavaScript and XML allows asynchronous updating of the webpage so that part of the page may be updated without reloading the entire page every time.

38. What is meant by Web Services in ASP.NET?

Web Services are software programs that use common protocols to exchange information with other software using XML.

39. What components does ADO.NET have?

ADO.NET components include Dataset, Data Adaptor, Data Reader, Connection, and Command.

40. What is the File Extension of Web Service?

The File Extension for Web Service is .asmx.

41. What protocol is used to call a Web Service?

The HTTP or Hypertext Transfer Protocol is used to call Web service.

42. What are the types of caching in ASP.NET?

Three kinds of caching are available:

  • Output Caching
  • Fragment Caching
  • Data Caching

43. How is an Event Handler added?

The Attributes property of Server Side Control is used to handle an event.

44. What is the base class for inheriting all Web Forms?

The Page class is the base class from which all Web Forms are inherited.

45. Can Web Services support a data reader?

No, Web Services support a dataset, but not a data reader.


×