Skip to main content

Latest Dot Net Interview Questions and Answers

[1] What is the managed and unmanaged code in .net?

The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime s functionality and enable you to write code that benefits from this managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code; it benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.

[2] What are the memory-mapped files?

Memory-mapped files are used to map the content of a file to the logical address of an application. It makes you able to run multiple processes on the same machine to share data with each other. To obtain a memory-mapped file object, you can use the method MemoryMappedFile.CreateFromFiles( ). It represents a persistent memory-mapped file from a file on disk.

[3] Explain GridView control in ASP.NET?

The GridView control displays the values of a data source in a table. Each column represents a field, while each row represents a record.

The GridView control supports the following features:

  • Binding to data source controls, such as SqlDataSource.
  • Built-in sort capabilities.
  • Built-in update and delete capabilities.
  • Built-in paging capabilities.
  • Built-in row selection capabilities.
  • Programmatic access to the GridView object model to dynamically set properties, handle events, and so on.
  • Multiple key fields.
  • Multiple data fields for the hyperlink columns.
  • Customizable appearance through themes and styles.
  • Creating a GridView.

[4] What is the difference between ASP.NET Web API and WCF?

The ASP. NET Web API is a framework that uses the HTTP services and makes it easy to provide a response to the client request. The response depends on the request of the clients. The Web API builds the HTTP services and handles the request using the HTTP protocols. The request may be GET, POST, DELETE, PUT. We can also say that ASP. NET Web API:
Is an HTTP service.
Is designed for reaching the broad range of clients.
Uses the HTTP application.
We use ASP. NET Web API for creating the RESTful (Representational State Transfer) services.

The following are some important points of the ASP. NET Web API:
The ASP. NET Web API supports the MVC application features that are controller, media formatters, routing etcetera.
It is a platform for creating the REST services.
It is a framework for creating HTTP services.
Responses can be formatted by the APIs MediaTypeFormatter into the JavaScript Object Notation (JSON) and Extensible Markup Language (XML) formats.

[5] What are the defining traits of an object-oriented language?

The defining traits of an object-oriented language are:
a) Inheritance
b) Abstraction
c) Encapsulation
d) Polymorphism

Inheritance: The main class or the root class is called as a Base Class. Any class which is expected to have ALL properties of the base class along with its own is called a Derived class. The process of deriving such a class is Derived class.

Abstraction: Abstraction is creating models or classes of some broad concept. Abstraction can be achieved through Inheritance or even Composition.

Encapsulation: Encapsulation is a collection of functions of a class and object. The Food class is an encapsulated form. It is achieved by specifying which class can use which members (private, public, protected) of an object.

Polymorphism: Polymorphism means existing in different forms. Inheritance is an example of Polymorphism. A base class exists in different forms as derived classes. Operator overloading is an example of a Polymorphism in which an operator can be applied in different situations.

[6] What is a CLS (Common Language Specification)?

CLS is a specification that defines the rules to support language integration. This is done in such a way, that programs are written in any language (.NET compliant) can communicate with one another. This also can take full advantage of inheritance, polymorphism, exceptions, and other features. This is a subset of the CTS, which all .NET languages are expected to support.

[7] How can we apply themes in ASP.NET application?

A theme is a collection of settings that define the look of controls and web pages. These themes are applied across all the pages in a web application to maintain a consistent appearance. Themes are included images and skin files; the skin files set the visual properties of ASP.NET controls. Themes are of two types:

Page Theme:-
A Page theme contains the control skins, style sheets, graphic files, and other resources inside the subfolder of the App_Theme folder in the Solution Explorer window. A page theme is applied to a single page of the web site.

Global Theme:-
A Global theme is a theme that is applied to all the web sites on a web server and includes property settings, and graphics. This theme allows us to maintain all the websites on the same web server and define the same style for all the web pages of the web sites.

[8] Which method do you use to enforce garbage collection in .NET?

The System.GC.Collect() method.

[9] What are the different types of indexes in .Net?

There are two types of indexes in .Net:
Clustered index and non-clustered index.

[10] How can you identify that the page is posted back?

There is a property, named as IsPostBack property. You can check it to know that the page is post backed or not.

[11] What is the full form of ADO?

The full form of ADO is ActiveX Data Object.

[12] What is Click Once?

ClickOnce is a new deployment technology that allows you to create and publish self-updating applications that can be installed and run with minimal user interaction.

[13] What is Ajax in ASP.NET?

Ajax stands for Asynchronous JavaScript and XML; in other words, Ajax is the combination of various technologies such as JavaScript, CSS, XHTML, DOM, etc.

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the entire page.

We can also define Ajax is a combination of client-side technologies that provides asynchronous communication between the user interface and the web server so that partial page rendering occurs instead of complete page postback.

Ajax is platform-independent; in other words, AJAX is a cross-platform technology that can be used on any Operating System since it is based on XML & JavaScript. It also supports open source implementation of other technology. It partially renders the page to the server instead of complete page postback. We use AJAX for developing faster, better and more interactive web applications. AJAX uses an HTTP request between the webserver & browser.

With AJAX, when a user clicks a button, you can use JavaScript and DHTML to immediately update the UI, and spawn an asynchronous request to the server to fetch results.

When the response is generated, you can then use JavaScript and CSS to update your UI accordingly without refreshing the entire page. While this is happening, the form on the user,s screen doesn,t flash, blink, disappear, or stall.

The power of AJAX lies in its ability to communicate with the server asynchronously, using an XMLHttpRequest object without requiring a browser refresh.

Ajax essentially puts JavaScript technology and the XMLHttpRequest object between your Web form and the server.

[14] What is the global assembly cache (GAC)?

GAC is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC solves some of the problems associated with DLLs (DLL Hell).

[15] What is the use of Error Provider Control in .NET?

The ErrorProvider control is used to indicate invalid data on a data entry form. Using this control, you can attach error messages that display next to the control when the data is invalid, as seen in the following image. A red circle with an exclamation point blinks, and when the user mouses over the icon, the error message is displayed as a tooltip.

[16] What is the PostBack property in ASP.NET?

If we create a web page, which consists of one or more Web Controls that are configured to use AutoPostBack (Every Web controls will have their own AutoPostBack property), the ASP.NET adds a special JavaScipt function to the rendered HTML Page. This function is named _doPostBack() . When Called, it triggers a PostBack, sending data back to the webserver.

ASP.NET also adds two additional hidden input fields that are used to pass information back to the server. This information consists of the ID of the control that raised the event and any additional information if needed. These fields will empty initially as shown below,

The following actions will be taken place when a user changes a control that has the AutoPostBack property set to true:

On the client-side, the JavaScript _doPostBack function is invoked, and the page is re-submitted to the server.
ASP.NET re-creates the Page object using the .aspx file.
ASP.NET retrieves state information from the hidden view state field and updates the controls accordingly.
The Page. The load event is fired.
The appropriate change event is fired for the control. (If more than one control has been changed, the order of change events is undetermined.)
The Page.PreRender event fires and the page is rendered (transformed from a set of objects to an HTML page).
Finally, Page. Unload event is fired.
The new page is sent to the client.

[17] Explain Cookie-less Session in ASP.NET?

By default, a session uses a cookie in the background. To enable a cookie-less session, we need to change some configuration in the Web. Config file. Follow these steps:

Open Web.Config file.
Add a tag under the tag.
Add an attribute cookieless in the tag and set its value to AutoDetect like below:

The possible values for the cookieless attribute are:
AutoDetect: Session uses background cookie if cookies are enabled. If cookies are disabled, then the URL is used to store session information.
UseCookie: Session always uses background cookie. This is the default.
UseDeviceProfile: Session uses background cookie if the browser supports cookies else URL is used.
user: Session always uses URL. regenerateExpiredSessionId is used to ensure that if a cookieless URL is expired a new URL is created with a new session. And if the same cookieless URL is being used by multiple users at the same time, they all get a new regenerated session URL.

[18] How is it possible for .NET to support many languages?

The .NET language code is compiled to Microsoft Intermediate Language (MSIL). The generated code is called managed code. This managed code is run in a .NET environment. So after compilation, the language is not a barrier and the code can call or use the function of another language also.

[19] What is Themes in ASP.NET?

A theme decides the look and feel of the website. It is a collection of files that define the looks of a page. It can include skin files, CSS files & images.

We define themes in a special App_Themes folder. Inside this folder is one or more subfolders named Theme1, Theme2, etc. that define the actual themes. The theme property is applied late in the pages life cycle, effectively overriding any customization you may have for individual controls on your page.

How to apply themes

There are 3 different options to apply themes to our website:

Setting the theme at the page level: the Theme attribute is added to the page directive of the page.
Setting the theme at the site level: to set the theme for the entire website you can set the theme in the web.config of the website. Open the web.config file and locate the element and add the theme attribute to it:

Setting the theme programmatically at runtime: here the theme is set at runtime through coding. It should be applied earlier in the pages life cycle ie. Page_PreInit event should be handled for setting the theme. The better option is to apply this to the Base page class of the site as every page in the site inherits from this class.
Page.Theme = Theme1;
Uses of Themes

Since themes can contain CSS files, images, and skins, you can change colors, fonts, positioning, and images simply by applying the desired themes.

You can have as many themes as you want and you can switch between them by setting a single attribute in the web.config file or an individual apex page. Also, you can switch between themes programmatically.

Setting the themes programmatically, you are offering your users a quick and easy way to change the page to their likings.

Themes allow you to improve the usability of your site by giving users with vision problems the option to select a high contrast theme with large font size.

[20] What are the Navigations technique in ASP.NET?

Navigation can cause data loss if it not properly handled. We do have many techniques to transfer data from one page to another but every technique has its own importance and benefits.

We will discuss the following techniques in this article.

Cross page posting

Leave a Reply

Your email address will not be published.

Share via
Copy link
Powered by Social Snap