upGrad KnowledgeHut SkillFest Sale!

.NET Framework Interview Questions and Answers

.NET Framework is a flexible cross-platform software development framework developed by Microsoft that provides a platform for building, deploying, and running applications and services for desktop applications, web applications, and mobile applications. Our .NET experts and veteran interviewers have come up with the top .NET Framework interview questions and answers to give you that edge over others and successfully crack your next .NET Framework interview for beginner, intermediate and expert profiles in the .NET domain. Check the detailed explanations for questions on .NET topics like Common Language Runtime, Common Language Specification, Common Type System, code management, caching, assembly, GAC, MVC, MSIL, GAC, App state and lifecycle, user control and more. These .NET framework interview questions will be a great resource in order to crack your next .NET Framework job interview and more.

  • 4.7 Rating
  • 58 Question(s)
  • 30 Mins of Read
  • 10255 Reader(s)

Beginner

It is a platform which is developed by Microsoft for the software development. In the current scenario, the version used by the programmer is 4.7.1.

It is very effective when we want to create - Form-based and Web-based applications. Web services using the development tool, .Net framework.

It is multilingual in terms of a programming language. It uses C# or Visual Basic to develop the application, in this user can make its own choice by choosing its own language to develop the application

.Net Framework Architecture :

1. Language :

  • WinForms – This is used for developing Windows Forms applications, which runs on an end user machine. Example: Notepad.
  • ASP.Net – This is used for developing web applications which runs on browsers such as Internet Explorer, Chrome or Firefox
  • ADO.Net – This is used to develop applications that interact with Databases such as Oracle or Microsoft SQL Server

2. Class Library: .Net Framework included a number of class libraries which contain the method and function which helps in handling the file level operation. For example, a class library that has methods to handle all file-level operations like a method which can be used to read the text from a file

3. Common Language Runtime: Common Language Infrastructure has the following key features:

  • Exception Handling: Exceptions are errors which occur when the application is executed.like if you are opening the file from the local which is not present at the local then it will give an exception
  • Garbage Collection: when we wanted to remove the unwanted resources from the code which is no longer in use can be done by the garbage collector.

Like as the database connection in the application which is no longer in use when compilation stops

1. Common Language Runtime. It works as an interface between an Operating Systems and the applications which are developed using the .NET framework. The main objective of CLR is to execute the program by converting the managed code to native code. CLR 's Just In Time (JIT) compilation converts Intermediate Language (MSIL) to native code at application run time.

When .Net application is executed, then the control goes to Operating System, which creates a process to load CLR

2. CLR services

  • Assembly Resolver
  • Assembly Loader
  • Type Checker
  • COM marshaller
  • Debug Manager
  • Thread Support
  • IL to Native compiler
  • Exception Manager
  • Garbage Collector

3. Assembly Resolve

It will send the request to the assembly loader by identifying assembly whether it is private or shared assembly.

4. Assembly Loader

According to the assembly resolver instruction, the assembly loader loads the instruction into the application.

5. Type Checker

To provide the safety checker helps in verifying the types which are used in the application with CTS or CLS

6. COM marshaller

It helps in getting communicating with the COM components which supports the COM interoperability.

7. Debug Manager

Using this we can check the code by line by line according to that we can make the changes in the code without terminating the application execution.

8. Thread Support

It manages more than one execution path in the application process, this provides multithreading support.

9. IL to Native compiler

Just In Time (JIT) compiler is used to convert the IL code to native code.

10. Exception Manager

It will handle exceptions thrown by application by executing catch block provided by exception, if there is no catch block, it will terminate the application.

11. Garbage Collector

when we wanted to remove the unwanted resources from the code which is no longer in use can be done by the garbage collector.

Like as the database connection in the application which is no longer in use when compilation stops.

CLS stands for Common Language Specification as the name suggests it set of certain feature which is very helpful for library and compiler writers if any other language that supports CLS can be used fully in each other's language, thus we can say that CLS is a subset of the common type system.

It is actually a set of restrictions on the CTS. It not only defines the types allowed in external calls, but also the rules for using them, depending on the goal of the user.

CLS is basically a subset of the entire set of features supported by CLR. With CLS, we can call virtual methods or can overload methods and not include things such as unsigned types.

It defines a common level of language functionality. CLR is the set of rules that a language compiler must follow while creating a .NET application at run in CLR. Anyone who wants to write a .NET·-compliant compiler needs simply to adhere to these rules and that's it.CLS is a set of rules through which we can exchange information over a single platform. The beauty of this is that the restriction to use features only applies to public and protected members of classes public classes. Within the private methods of your classes, any non-CLS code can be written, because the code in other assemblies cannot access this part of your code

The Common Type System defines how types are declared, used, and managed in the common language runtime, and is also an important part of the runtime's support for cross-language integration.

Here we have several languages and each and every language has its own data type and 1 language data type cannot be understandable by other languages.

CTS is a specification created by Microsoft and included in the European Computer Manufacturer‘s Association standard. It has certain standard features for implementing the .NET framework.

There are different types which CTS Support:

  1. Value Types: It directly contains the data and instances are either allocated on the stack or allocated inline in a structure. Value types can be built-in, user-defined or enumerations types.
  2. Reference Types: Value’s memory address reference are stored and are allocated on the heap. This can be any of the pointer types, interface types or self-describing types.

Operations on variables of a value type do not affect any other variable, whereas, operations on variables of a reference type can affect the same object referred to by another variable.

Started in the 2000s, ASP.net is a widely used web application framework which runs on Windows. It allows the development of applications, dynamic website, and web services. The biggest benefit of designing websites using ASP.net is the low cost and high speed. It also Another great benefit is its vast language support. ASP.net doesn’t need to be installed or configured separately unlike other platforms since it is built into the Windows environment.

Developers are widely using the framework since it allows building websites that are much faster and dynamic. The reason is the codes are compiled rather than interpreted. This means that the code is converted into object code which can be executed repeatedly by the .Net platform. The compilation process takes little time and happens only once unlike interpretation in which the code is read and interpreted every time it is being executed.

ASP.net is written in OOP languages, i.e., Object Oriented Programming languages, such as VB.net and C#. This is the reason it is fast, easy to use and totally reliable.

.Net is a framework that offers the most unique programming guidelines to develop not only web solutions but also a range of applications. It is compatible with many programming languages such as F#, C++, VB.net, and C#.  It has a very easy to use Integrated Development Environment (IDE) where you can write your code. It also supports editing of the code, designing interface, performance analysis, debugging and server management. Apps created using .Net can be run on Windows, LINUX, and Mac OS X.

It has a huge collection of prewritten codes which are known as predefined class libraries. It’s the work of other developers that can easily be used by adding those code into your programs. .Net libraries also have pre-written codes for database connectivity, database access, encryption and security.

.Net framework is widely used by big MNCs and IT companies for its varied advantages. Some loyalists are HCL, TCS, Dell, Epic Systems, Accenture, Quicken Loans, etc.

Both VB.net and C# use Object Oriented Programming Language and run on the .Net framework. These High-Level Languages are also referred to as Common Language Infrastructure (CLI) languages which means their code need not be translated while getting executed on a different platform.

Although they have many things in common, their main differences are as follows.

C#

  • C# comes with all the features of Python, Java, C++, and other languages since it is evolved from C.
  • To declare variables, the users must define their own variables or use the built-in types.
  • By using keywords in C#, unmanaged resources can be released.
  • Optional parameter is not supported in C#.
  • C# allows new implementation without overriding the base class member. The base class member can be used in a derived class just with the keyword ‘new.

VB.net

  • VB.net is user-friendly since it uses mnemonics and is much similar to the English language. It can be easily learned.
  • To declare variables in VB.net, classes, Private, Public, Protected, Friend, and Static must be used.
  • The feature of releasing unmanaged resources is not available in VB.net.
  • An optional parameter is supported in VB.net.
  • In VB.net, a new implementation of base class without overriding the base class member is allowed. The base class member can be used in a derived class just with the keyword ‘Shadows’.

Managed Code: Managed Code is the code which isn’t run by the operating system directly. It is implemented in the run time environment. There are many benefits of Managed runtime such as type checking, garbage collection, bound checking, exception handling, etc. without the need for interference from the programmer.

The compiler compiles the code in the .Net framework and translates into an intermediate language, MSIL. It is then translated to executable code.

Managed Code in .NET

Unmanaged Code: Unmanaged code is not translated to executable code. It directly runs on the operating system. On every platform an unmanaged code runs, it is compiled separately. The reason is that it depends on the architecture of the system. Since it is compiled into a to native code, it can lead to many problems such as pointer override, buffer overflow, memory leak, etc. Unmanaged code provides direct access to the hardware and is not 100% secure to create applications.

Unmanaged Code in .NET

Caching is a technique that is used to store data that is frequently used in memory. The runtime of ASP.net has a key-value map which is called the cache. It reduces the execution time when the next time the same information is requested. The code will not need to be generated since the pages can be retrieved directly from the memory. Caching is very important to transactions related to data because of its quick response time.

The data will be unavailable in certain situations:

  • When the process doesn’t take place for any reason
  • The memory is released from the application
  • The lifetime of the data is expired

The items inside the cache can be accessed using an indexer. It can also be used to control and link the objects to each other.  

  • Output Caching: When the page is requested again, a cached copy is sent.
  • Data Caching: Refills the cache when it is expired.
  • Object Caching: Caches the objects.

A must-know for anyone looking for dot NET coding interview questions, this is one of the most common dot NET questions to ask a programmer.

.Net framework basically is a platform for building multiple applications on windows. It has various inbuilt functionalities available in various forms like class, library, and APIs which are used in building, deploying and running the web services and N no of other applications. It even supports various languages such as C#, COBOL, Perl, VB.Net, etc.

This framework actually supports a programming model that is object-oriented.

It is also an open-source, server-side, web application framework designed for web development resulting in web pages which are dynamics by nature.

This framework came into existence through Microsoft to allow programmers to build web sites, web applications and web services that are dynamic by nature.

In nutshell .Net framework is meant for creating applications, which would run on the Windows as well as web Platform. The .Net framework’s 1st version was released in the year 2002.

4 main components of .Net Framework are mentioned below:

  • CLR(Common Language Runtime)
  • CTS(Common type system)
  • BCL(Base Class Library)
  • CLS(Common Language Specification)

1. CTS stands for Common Type System

It has a lot of guidelines which state how an information type ought to be proclaimed, characterized and utilized in the program. It portrays the information types that are to be utilized in the application.

We can plan our own classes and qualities by following the principles that are available in the CTS. The principles are made with the goal that the information type pronounced utilizing a programming language is callable by an application that is created utilizing an alternate language.

2. CLR stands for Common Language Runtime.

It is one of the most significant parts of the .Net structure. It gives building squares to numerous applications.

An application assembled utilizing C# gets incorporated by its own compiler and is changed over into an Intermediate language. This is then focused on CLR. CLR does different tasks like memory the executives, Security checks, congregations to be stacked and string the board. It gives a protected execution condition to applications.

3. CLS stands for Common Language Specification

With the rules mentioned under CLS, the developers are made to use the components that are inter-language compatible. They are reusable across all the .Net compliant languages.

4. BCL stands for Base Class Library

BCL otherwise called the Class library (CL). BCL is a subset of Framework class library (FCL). Class library is the accumulation of reusable sorts that are firmly incorporated with CLR. Base Class library gives classes and types that are useful in performing an everyday task, for example, managing string and crude sorts, database association, IO activities.

JIT is abbreviated as Just In Time. It acts as a compiler that helps in converting the Intermediate Language to a Native code. The code is generally available in Native language during the execution step. Native code is actually nothing special but the hardware specifications that can be easily understood by the CPU.

The native code even is stored so that it is accessible for subsequent calls by the end-users.

In short, it converts the MSIL code within an assembly to native code that can be understood by the CPU architecture of the target machine to run a .NET application.. It also cross-checks the values that are passed to parameters of any method.

It helps in managing the execution of .NET programs regardless of any type of .NET programming language. The first step is a language-specific compiler converting the source code to the intermediate language. Then the intermediate language is transformed into the machine code by the JIT compiler.

The code being managed by the CLR is called Managed code. This code basically runs within the CLR. Thus, it is important to get the .Net framework installed in order to execute the managed code. CLR manages its memory through garbage collection and even uses the other features of .Net like CAS and CTS for proper and perfect management of the code.

Following steps are followed while executing a Managed code:

  • Step I: It involves choosing a language compiler which entirely depends on the language in which the code is written.
  • Step II: Converting the above-achieved code into an Intermediate Language with the help of its own compiler.
  • Step III: The Intermediate Language is then targeted to CLR followed by conversion into native code with the help of JIT compiler.
  • Step IV: The final step involves the execution of the Native code.

On the other hand, Unmanaged code is any code that does not at all depend on CLR for execution which means it is developed by any other language other than .Net framework.

It even uses its own runtime environment for compiling and execution of the data. 

Though it is not being run inside the CLR, but the unmanaged code works properly if all the other parameters are correctly mentioned here.

An assembly is a combination of logical units. The Logical units here mean the types and resources which are needed to build and deploy any application using the .Net framework. It is the standard parameter developed with the Microsoft.NET.

They might be executable (.exe) file or available in dynamic link library (DLL) file.

An assembly consists of either single file or multiple files for use. In conditions wherein we have multi-file, there is only one master module containing the manifest where as other assemblies exist as non-manifest modules.

A module in .NET is defined as a subpart of a multi-file. To add on further assembly is actually one of the most interesting and extremely useful areas of .NET architecture along with the feature of reflections and attributes.

In .NET there are basically three types of assemblies:

  • private
  • shared
  • satellite

Don't be surprised if this question pops up as one of the top interview questions on the dot NET framework in your next interview.

  • Private Assembly

Private assembly functions by coping in application folders separately, where we require to use the assembly’s functionalities;

In this case, the features does not function without copying. In short, it means every time we have to exclusively copy into the BIN folder of each application folder for the functioning of the private assembly.

  • Public Assembly

Public assembly is also known as Shared assembly does not require to copy separately into all application folders. Only one single copy is required at system level. Like the private assembly, there is no need to copy the assembly into the application folder.

It should be installed in GAC (Global assembly cache).

  • Satellite Assembly

The language and culture-specific resources for an application are being deployed with the help of satellite assembly.

This is one of the common dot NET framework interview questions for freshers, don't miss this one.

The two Assembly executable modules are EXE and DLL.

Exe in simple words means an executable file that is generated when we build an application. The assemblies are directly loaded when we run an Exe. Meanwhile, an Exe cannot be shared with the other applications. It is a file extension for an executable file format. An executable file can be easily run by a program in Microsoft DOS or Windows through a command or a double click.

DLL stands for Dynamic Link Library. It is a library that has codes that are hidden. The codes are actually encapsulated inside the library. An Application can consist of n number of DLLs which can be shared with the other applications as well. Other applications that need to share this DLL need not worry about the code till the time they are able to call the function on this DLL.

DLL files can be used by more than one program at a time. In fact, they can even be used by multiple programs being executed within the same time. DLLs usually come with the Windows operating system while some of them are added when new programs are being installed.

A cache essentially stores the output produced by a page in the memory and this output in the cache will serve us (clients) later on.

Caching acts as a storage tank for the applications to access data temporarily rather than looking for its original location. In other words, it is a memory for applications to be executed which in turn increases the efficiency of the performance of the application along with its speed. 

It is actually a good habit for the coder to use caching at the time of building the application. It is one of the most interesting concepts and operations in asp.net.

Depending upon the requirement we can run any application by applying the caching concept.

Caching provides solutions or results to the end users depending on their request. Admin then comes into the picture and needs to recreate the pages.

Given below are the 3 different types of Caching:

  • Page Caching
  • Data Caching
  • Fragment Caching

For page caching, we need to specify @OutputCache directive at the top of the page as per the following syntax:

<%@ OutputCache Duration=5 VaryByParam="None" %>

As should be obvious, there are two attributes to this. They are:

  • Duration - The time in seconds of to what extent the output ought to be reserved. After the predefined length has passed, the cached output will be expelled and page content created for the following new request. That yield will again be reserved for 5 seconds and the procedure repeats.
  • VaryByParam - This characteristic is mandatory and indicates the querystring parameters to differ the reserve.

In the above piece, we have indicated the VaryByParam value as None which means the page content to be served is the equivalent paying little mind to the parameters went through the querystring.

On the off chance that there are two requests to a similar page with fluctuating querystring parameters, e.g.:

.../PageCachingByParam.aspx?id=10 and .../PageCachingByParam.aspx?id=11]

A separate page content is produced for every one of them, the mandate ought to be:

<%@ OutputCache Duration=5 VaryByParam="id" %>

The page content for the two requests will each be stored for the time indicated by the Duration characteristic

To determine numerous parameters, use a semicolon to isolate the parameter names. On the off chance that we indicate the VaryByParam property as *, the reserved substance is shifted for all parameters went through the querystring.

A few pages create distinctive substances for various programs. In such cases, there is an arrangement to shift the reserved yield for various programs. The @OutputCache order must be changed to:

<%@ OutputCache Duration=5 VaryByParam="id" VaryByCustom="browser" %>

This will change the stored yield for the browser as well as its versions. I.e., IE5, IE 6, Netscape 4, Netscape 6 will all get distinctive cached versions of the output.

ASP.NET additionally supports the caching of information as objects. We can store objects in memory and use them crosswise over different pages in our application. This element is actualized utilizing the Cache class. This cache has a lifetime equal to that of the application. Objects can be put away as name-value pairs in the cache. A string can be embedded into the cache as pursues:

Cache["name"]="Dhruv";

The cached string value can be fetched like this:

if (Cache["name"] != null)
Labe12.Text= Cache["name"].ToString();

To embed objects into the Cache, the Add() or various forms of the Insert() of the Cache class can be utilized. These methods enable us to utilize the more dominant features given by the Cache class. One of the over-burdens of the Insert method is utilized as pursues:

Cache.Insert("Name", strName, new CacheDependency(Server.MapPath("name.txt"), DateTime.Now.AddMinutes(2), TimeSpan.Zero);

The initial two parameters are the key and the object to be embedded. The third parameter is of sort CacheDependency and encourages us to set a reliance on this value to the document named name.txt. So at whatever point this document changes, the value in the cache is expired. We can mention NULL to show no dependency on this. The fourth parameter indicates the time at which the value ought to be deleted from the cache. The last parameter is the sliding expiration parameter which demonstrates the time interim after which the object is to be expelled from the cache after this time.

The cache consequently expels the least utilized things from memory, when framework memory turns out to below. This procedure is called scavenging. We can mention priority for the objects that are added to cache so that those few things are given more importance than others:

Cache.Insert("Name", strName, new CacheDependency(Server.MapPath("name.txt"), DateTime.Now.AddMinutes(2), TimeSpan.Zero, CacheItemPriority.High, null);

The CacheItemPriority sets the priority level to an item. The CacheItemPriority.High allocates a high-level priority to an item with the goal that this is most drastically averse to be erased from the store.

In some cases we should store just parts of a page. For instance, we may have a header for our page which will have similar content for all clients. There may be some content/picture in the header which may change regularly. All things considered, we will need to store this header for a span of a day.

This can be achieved by using user controls (.ascx) in web form. In asp.net for each user control we can set cache durations separately. The arrangement is to put the header content into a user control and afterward indicate that the user control content ought to be cached. This system is called fragment caching.

To indicate that a user control ought to be reserved, we utilize the @OutputCache order simply like we utilized it for the page.

This is one of the common dot NET framework interview questions for freshers with answers, don't miss this one.

GAC stands for Global Assembly Cache.

  • Any computer where the CLR is installed has a global assembly cache.
  • Global Assembly Cache stores assemblies designated to be shared by multiple applications.
  • It's a method to store DLLs in such a way that it can be accessible globally without worrying about any conflicts.
  • Versioning is simple on the grounds that the GAC can hold numerous versions of the same DLLs without any issues.
  • Bin folder of the application containing the local copy of DLL isn't required, so a couple of megabytes can be saved on the hard drive.
  • Assembly can be installed in GAC by using a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided in the Windows Software Development Kit (SDK).

Add, Remove and View Assemblies in the GAC

  • To install an assembly in the GAC, use the command as below:
gacutil /i “C:\someFolder\SomeAssembly.dll”

Note: full path must be mentioned so that the tool gets the correct assembly.

  • To remove an assembly from the GAC, use the command as below:
gacutil /u SomeAssembly

Note: Only an assembly name is required. This command will remove all versions of the assembly.

  • To remove a specific version of an assembly, additional versioning information is required:
gacutil / u SomeAssembly, Version = 1.1.1.1
  • To view the contents of the GAC:

gacutil / l

Namespace

  • It is a logical grouping of classes that belongs to the same functionality.
  • Example: System.Data & System. Web are namespaces.

Assembly

  • Act as the building block of .NET Framework applications.
  • It is a group of types & resources which work together to create a logical unit of functionality.
  • An assembly is a precompiled code that can be executed by the .NET environment.
  • It may contain one or more than one Namespaces.
  • Any .NET program can consists of one or more assemblies.
  • Example: System.Web.dll and System.Data.dll are assemblies.
  • In the other way we can say an assembly is a project. Each project within a same solution, gets compiled into its own individual assembly.
  • An assembly can have multiple namespaces.

.NET is a designer stage comprised of programming languages, tools, and libraries for constructing a wide range of applications. ASP.NET implemented on a .NET platform using tools and libraries specifically for designing web apps.

ASP represents Active Server Pages. ASP.Net is a piece of .Net technology and it contains CLR as well. It is an open source server-side innovation that empowers the developers to fabricate amazing web administrations, sites, and web applications. It is a structure created by Microsoft on which we can grow new age sites utilizing web forms (aspx), MVC, HTML, JavaScript, and CSS and so on. It is a successor of Microsoft Active Server Pages (ASP).

These are a few things that ASP.NET adds to the .NET stage:

  • Basic framework for handling web request/response
  • Template for Website like RAZOR for dynamic web pages
  • Libraries for basic web patterns, for example, Model View Controller (MVC)
  • Providing an authentication framework that incorporates libraries, a database, and layout pages for taking care of logins, including multifactor and external authentication.

In Classic ASP is stateless i.e. no real state management technique is implemented. If you wish to identify the user an additional code needs to be implemented

In contrast to this, .Net provides session & application state management techniques.

ASP.NET has some additional methods which can be used to persist data in addition to the Session variables, which is commonly used in classic ASP. These include ViewState and ControlState. This means that some of the tedious work from ASP such as storing information in hidden variables and then re-populating and updating these values with each post or get is automatically handled by ASP.NET.

MVC is a framework used to make web applications. It is a design model for building the .Net applications. The web application base expands on Model-View-Controller design which isolates the application rationale from UI, and input by the user will be constrained by the Controller.

  • The Model

The model is responsible for managing the data of the application. It responds to the request from the view and it also responds to instructions from the controller to update itself.

  • The View

It implies the introduction of information in a specific format, activated by a controller's choice to present the information. It uses the data prepared by the Controller to generate a final presentable response. They are script-based templating frameworks like JSP, ASP, PHP and simple to incorporate with AJAX innovation.

  • The Controller

The controller is in charge of reacting to the client input and perform interaction on the model objects. The controller gets the input, it approves the input and perform the business task that changes the state of data objects.

Advanced

Code can be compiled into an intermediate language, so we cannot run it directly on the computer as native code. Managed code runs in the Common Language Runtime.

Key features of managed code are:

  • Managed code increases the performance gain of the application as well as it doesn`t require extra security features while using unmanaged code we require extra security to increase the performance of the application
  • It includes the garbage collection and scalability feature, which is the lifetime control of object
  • It makes the deployment easy and improves the version facilities at the end of dll.
  • It provides Built-in security by using code access security and avoiding buffer overruns.

Managed code runs entirely "inside the sandbox," meaning that it cannot make calls outside of the .NET Framework.  To perform more safely and efficiently we use managed code to get the maximum benefit from the features of the .NET Framework.

Code in VB.NET and C is the managed code. If you're working with those applications, you are making managed code. We can use managed code using C++ according to the choice of the user.

This is one of the most frequently asked dot NET framework interview questions for freshers in recent times.

A .NET programming language like C#, VB.NET etc., not directly compiled into executable code; instead, they compile into an intermediate code called Microsoft Intermediate Language (MSIL). Since it automatically converts to MSI, so the programmer doesn’t need to be worried about that.

MSIL is similar to Java Byte code. A Java program is compiled into Java Byte code (the .class file) by a Java compiler, the class file is then sent to JVM which converts it into the host machine language.

Along with the Microsoft Intermediate Language MSIL the compiler also produces the MetaData which are contained in the portable executable PE file when the compiler produces MSIL it provides some instruction like  loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations

 Advantages -

  • MSIL provides language interoperability as code is written in any .net language is compiled into MSIL.
  • Same performance for all .net languages
  • It provides support to different runtime environments
  • JIT compiler in CLR converts MSIL code into native machine code which is executed by OS

JIT (JUST-IN-TIME) is a Compiler before MSIL be executed, it first converted to native code by .NET framework Just In Time(JIT) compiler, which runs on the same System on which the JIT Compiler is executing.

Just-in-time (JIT) is a term that is used to describe any action like compilation or object activation that only happens when it is necessary. This term is associated mostly with software compilation. It is designed because it has features to be accessed on multiple platforms and it also has high speed.

In Microsoft .NET there are three types of JIT (Just-In-Time) compilers :

  • Pre-JIT Compiler: It compiles complete source code into native code in a single compilation cycle. It converts the .NET code from platform independent state to platform-specific stage.
  • Econo JIT Compiler: It compiles only those methods that call at runtime and once these compiles methods are not in use are removed. Econo JIT spends less time compiling so startup latency is lower for interactive applications.
  • Normal JIT Compiler: It compiles only those methods that are called at runtime, and after the execution of these methods is stored in memory, it is commonly referred to as “Jitted”. Methods that are compiled once are not compiled again.

All windows executable files and assemblies follow the Portable executable file formats.

.NET PE file format consists of four parts:

  1. PE/COFF Headers: it contains information regarding exe or dll files.
  2. CLR Header: contains information about CLR, memory management and CLR other related stuff.
  3. CLR Data: Contains metadata of ddls and MSIL code generated by compilers.
  4. Native image section: contains native image section like .data, .rdata, .rsrc, .text etc

All .NET assemblies are built over the PE file formats, that is used for all exes and dlls, which itself are built over the MS-DOS executable file formats.

Most of PE files are split up into separate sections, where each section stores different types of data. Like: .text stores all executable code, .rsrc store unmanaged resources, .debug stores debugging information, .data section stores the global variables..etc.,.

A PE file has headers and sections that tell the dynamic linker about how to map file into memory. The task of the dynamic linker is to map each section of the memory and assign the correct permissions to the resulting regions, according to the instructions found in the headers

In a .NET framework executable, the PE code section is having a stub that invokes the CLR virtual machine startup entry, _CorExeMain or _CorDllMain in mscoree.dll, which is much the same as in Visual Basic executables.

The development on this platform intends to be binary compatible with Microsoft .NET, it uses the same PE format as the Microsoft implementation.

This is one of the most frequently asked dot NET framework interview questions and answers for freshers in recent times.

Microsoft .NET Framework application is a primary unit for deployment in Asp.Net.It provides all required execution information to common language runtime so It is called as the building block of an application.

In .NET, there are two kinds of assemblies,

  1. Single file
  2. Multi file.

An assembly that contains all information like IL, Metadata, and Manifest  in a single package is called as single file assembly. Most of the assemblies in .NET are build up as a single file assemblies.

Multiple file assemblies contain the multiple .NET binaries which are generated for bigger applications. In this, there will always be one assembly which will contain a manifest and while others will have IL and Metadata instructions.

Assembly has the code that the common language runtime(CLR) executes. Microsoft intermediate language (MSIL) code will not be executed the portable executable (PE) file if it does not have an associated assembly manifest.

It resides in each and every type’s identity which includes the name of the assembly. A type which is called MyType is loaded in the scope of one assembly and it is not the same as the type which is called MyType which is loaded in the scope of another assembly.

Assemblies can be of static or dynamic type. Static assemblies are those which include .NET Framework types (interfaces and classes), also if it is having the resources for the assembly (bitmaps, JPEG files, resource files, and so on). it is stored on disk in portable executable (PE) files. We can also create dynamic assemblies using a .NET framework, which can run directly from memory and will not save in the disk before execution. You can save dynamic assemblies to disk after their execution.

There are two kinds of assemblies in .NET;

  1. Private
  2. Shared

Private assemblies are very simple as they can be easily called upon each time from the assembly folder.

Shared assemblies known as a strongly named assembly are copied at a single location (usually GAC). For applications that are using the same assemblies, the same copy of shared assemblies are called from its original location, and hence they are not copied to each applications private folder. Each shared assembly has the four part name which includes its face name, version, public key token and culture information.

GAC stands for Global Assembly Cache.

  • It reserves an area for .NET Application to store the assemblies in the memory running on a certain machine.
  • It helps in sharing the assemblies to all .NET application.
  • To install in GAC, assemblies must have a strong name and must be publicly shared.
  • by using Graphical User interface and the command line tool we can work with a cache by installing the CLR which has the global assembly cache and the one with windows shell extensions this is called as Global Assembly Cache tool (Gacutil.exe).
  • The .NET Framework provides two tools for working with cache

When we want to share the assembly to the whole application then we use GAC which is stored in the folder of windows directory The concept of GAC is the result of the .NET architecture whose design addresses the issue of "DLL hell" that existed in COM (Component Object Model). In .Net there is no need to register the assembly before taking it in use. We can easily access it globally since it will not conflict by identifying its name, version, architecture, culture and public key

It has a certain feature of a shared library where different users can use the file which is stored in a common folder. In .NET 4.0, its default location is: %windir%\Microsoft.NET\assembly

There are two tools related to GAC are:

  1. GAC Tool (gacutil.exe): It is used to check for assembly existence, to register the shared assembly and to view and manipulate GAC contents.
  2. Assembly Cache Viewer (shfusion.dll): It helps in displaying the details like version, culture etc. with the assemblies which are associated with it in the cache.
  • Dispose: - Dispose helps to release the object resources from the object and not access them again. It basically helps in external memory clean up.it uses the Dispose() method to free up all its expensive resources and making it for reuse, and IDisposable interface is used which decides where and how Dispose() is used.
  • Finalize :- If Dispose is not called then Finalize() method is called for the cleanup, when we don’t want to clean up the memory immediately and want to de-allocating the memory later we use Finalization. If Dispose does not call, then garbage collector uses the finalize() method.
DisposeFinalize
It is used to free unmanaged items like file or Database connectionIt can be used to free unmanaged items like files, database connections etc. held by an object before that object is destroyed
It belongs to IDisposable interfaceIt belongs to Object class
Called from user code and the class which is implementing dispose methodOnly called by Garbage Collector and not by user code

The .NET application is said to be multilingual because we can deploy it in different language, the language it supports are visual basics, .NET, C#, J# which compiled to a command Intermediate language the Java byte code which is developed by Microsoft is a low-level language with simple syntax which is easily be translated into native machine code

  • CLR:

CLR helps .NET framework to be multilingual, the code running under CLR is termed as managed code, the main task of CLR is to convert compiled code into native code, it has different compilers some of them are

VB .NET, C#, C++, JScript or any third party compiler such as COBOL.

It simply means that you can create pages in different languages (like C#, VB .NET, J# etc.) and once all of these pages are compiled they all can be used in a single application

  • CTS:

CTS is Common Type System it is used when we are using the managing types, it is basically used to handle the data types. .NET have many languages and each language is having many other data types one language data types cannot be used in other languages, so in that case, we use the CTS

Example: we have the application in C# which is having the data type of int and there is another data type of integer in VB.NET, them CTS helps in converting the integer into the int32 structure.

  • CLS: 

It is Common Language Specification, it has developed certain rules which everyone used to follow like if we have created the code for the multiple inheritances in C++ and if use that code in c# and it will not compile since multiple inheritance is not allowed in C# also it makes C# a case sensitive members of the same class cannot have the same name like Add() and add() they consider as different function.

Expect to come across this, one of the most important dot NET interview questions for experienced professionals in software development, in your next interviews.

When we want to record the unusual activity during runtime, .net takes the help of the trace by following the page execution path which displays the information at run time

There are 2 levels of tracing used in .NET

  1. Page Level Tracing
  2. Application level Tracing

Page Level Tracing: it is for managing the trace of the page whether it is enabled or disabled, if it is enabled then a page which is requested, it appends to the page a series of tables containing the details of page request during execution

In this there are 2 Trace Modes:

  • SortByCategory: In this, it sort trace message according to the categories
  • SortByTime: In this, it sorts the message according to the order in which they are processed.

Application Level tracing: In this, we can set the trace for the whole application at once instead of setting for individual page, it is useful when we want to trace for the whole application instead of enabling and disabling for an individual page

We can trace the information according to the request limit we have to specify the default number is 10, as soon as it reaches the request limit it stops tracing.

When an object is created in C#, CLR (normal language runtime) assigns memory for that object from the heap. This procedure is repeated for every newly created variable/object, however, there is a drawback to everything, Memory isn't unrestricted and we have to clean some utilized space so as to prepare for new items. Here, comes the garbage collection is a picture. Garbage Collector manages distribution & recovering of memory. GC makes an outing to the heap and gathers all objects that are no longer utilized by the application and free up the memory.

The Garbage Collection is a significant technique in the .Net framework to free the unused managed code data in the memory. In the Common Language Runtime (CLR), the Garbage Collector acts as an automatic memory manager. It gives the following advantages:

  • Empowers you to build up your application without liberating memory.
  • Assigns objects to the managed heap efficiently.
  • Recovers objects that are never again being utilized, clears their memory and keeps the memory accessible for future allotments.
  • Gives memory security by ensuring that an object can't utilize the content of another object.

One of the most frequently posed dot NET interview questions, be ready for this conceptual question.

Certain Garbage Collection ought to be dealt with by the .Net structure. At the point when the object is created then it will be put in the Generation 0. The Garbage Collection utilizes an algorithm which checks the object’s in the age by identifying its current generation number. Once the object’s lifetime is over then it will be expelled from the memory. The two sorts of items. One is Live Objects and Dead Objects. The Garbage Collection algorithm gathers every single unused object that are dead objects in the age. In the event that the live objects running for long time, at that point dependent on that lifetime it will be moved to the next generation.

The object cleaning in the age won't happen precisely after the existence time over of the specific object. At some particular time Garbage Collection starts acting on it & implement its sweeping algorithm to free up the spaces.

There are no particular timings for Garbage Collector to get activated. Garbage Collection happens when one of the accompanying conditions is valid:

  • The system has low physical memory. This is recognized by either the low memory warning from the operating system or low memory demonstrated by the host. At the point when an allocation of virtual memory is requested, the virtual memory manager needs to locate a single free block that is enormous enough to fulfill that portion demand. Regardless of whether you have 2 GB of free space, the portion that requires 2 GB will be ineffective except if the majority of that free space is in a single address block.
  • The memory that is utilized by allocated objects on the managed heap exceeds an acceptable limit. This limit is continuously balanced as the process runs.
  • The GC.Collect method is called. In practically all cases, you don't need to call this technique, in light of the fact that the Garbage Collector runs continuously. This technique is principally utilized for extraordinary circumstances and testing.

a) User sends a solicitation to the IIS

  • IIS first checks which ISAPI expansion can serve this solicitation. Contingent upon document augmentation the solicitation is handled.

b) An occasion of the ApplicationManager class is made, which is the Application Domain that the solicitation is handled in.

  • As we as a whole know, the application space makes separation between two web applications facilitated on similar IIS. So on the off chance that there is an issue in one application space, it doesn't influence the other application area.

c) In the application space, an occasion of the HostingEnvironment class for example the 'HttpRuntime' object is made, which gives access to data about the application, for example, the name of the organizer where the application is put away.

d) Once the facilitating condition is made, the essential center ASP.NET items like 'HttpContext', 'HttpRequest' and 'HttpResponse' objects are made.

e) The application is begun by making a case of the HttpApplication class. On the off chance that the application has a Global.asax document, ASP.NET rather makes an occasion of the Global.asax class that is gotten from the HttpApplication class.

  • HttpApplication cases may be reused for numerous solicitations.

f) Once 'HttpApplication' is made, it begins preparing demands. It experiences following 4 stages:

  • (M: HttpModule): Client solicitation handling begins. Before the ASP.NET motor proceeds to make the ASP.NET HttpModule radiate occasions which can be utilized to infuse modified rationale. There are 6 significant occasions that you can use before your page item is made:
    • BeginRequest
    • AuthenticateRequest
    • AuthorizeRequest
    • ResolveRequestCache
    • AcquireRequestState
    • PreRequestHandlerExecute.
  • (H: 'HttpHandler'): Once the over 6 occasions are terminated, ASP.NET motor will summon ProcessRequest occasion in the event that you have executed HttpHandler in your task.
  • (P: ASP.NET page): Once the HttpHandler rationale executes, the ASP.NET page item is made. While the ASP.NET page item is made, numerous occasions are terminated which can assist us with writing our custom rationale inside those page occasions.
  • (M: HttpModule): Once the page article is executed and emptied from memory, HttpModule gives post page execution occasions which can be utilized to infuse custom post-handling rationale. There are 4 significant post-handling occasions PostRequestHandlerExecute, ReleaserequestState, UpdateRequestCache and EndRequest.

This is one of the most frequently asked ASP.NET framework interview questions and answers for freshers in recent times.

  • PreInit: This event is raised after the start stage is complete and before the initialization stage.
  • Init: This event occurs after all controls have been initialized. We can use this event to read or initialize control properties.
  • InitComplete: This event occurs at the end of the page's initialization stage. We can use this event to make changes to view state that we want to make sure are persisted after the next postback.
  • PreLoad: This event occurs before the postback data is loaded in the controls.
  • Load: This event is raised for the page first time and then recursively for all child controls.
  • Control events: This event is used to handle specific control events such as Button control' Click event.
  • LoadComplete: This event occurs at the end of the event-handling stage. We can use this event for tasks that require all other controls on the page be loaded.
  • PreRender: This event occurs after the page object has created all controls that are required in order to render the page.
  • PreRenderComplete: This event occurs after each data bound control whose DataSourceID property is set calls its DataBind method.
  • SaveStateComplete: It is raised after view state and control state have been saved for the page and for all controls.
  • Render: This is not an event; instead, at this stage of processing, the Page object calls this method on each control.
  • Unload: This event raised for each control and then for the page.

State Management is to protect state control in an application in light of the fact that ASP.NET web applications are stateless. Another instance of the Web page class is made each time the page is posted to the server. When a client enters data into a web application, that data would be lost in the round excursion from the program (MSDN).

In a solitary line, State Management keeps up and stores the data of any client till the finish of the client session. There are two types of state management techniques available:

  • Client Side
    • Storing data on the client in various ways.
    • Client-Side state management techniques are as follows:
    • View state (used by default by ASP .NET)
    • Control state
    • Hidden fields
    • Cookies
    • Query string
  • Server Side
    • Storing data in memory on the server
    • Server-Side state management techniques are as follows:
      • Application state
      • Session state

Client-Side:

  • For better scalability by saving user’s data at client-side(browser)
  • To support multiple servers, so, when a request is diverted to another server no need to worry about the state.
  • To empower the server-side states to be capable to help numerous servers you'll need to utilize techniques like a sticky connection for load balancing.

Server Side

  • Pick server-side for better security and to decrease data transfer capacity and website page's size.
  • Server side state management is more secure. The state is saved on the server also, consequently isn't conveyed to the client.
  • Secret state information shouldn't be utilized with client-side state management
  • Server-side diminishes the traffic to and from the user since information isn't sent to the browser and, it's saved on the server.
  • Client-side state management technique increases bandwidth usage & therefore application becomes less responsive and you'll experience performance issues.

ASP.NET page has by default EnableViewState property true. This makes ASP.NET consequently monitor the condition of the considerable number of controls present on the page. Presently on the off chance that I am dealing with a web page where I realize every one of the controls will be dynamically bound to certain information on each postback, I don't need to monitor the old data for the controls. So I may choose to turn it off. Presently this is a decent decision however things could get chaotic if a similar page contains a custom control and that custom control is utilizing ViewState to deal with the information inside the control.

So, ASP.NET already provides a technique to handle such scenarios and it's called ControlState.

At whatever point we build up a custom control and need to safeguard some data, we can utilize view state yet assume view state is disabled explicitly by the client, the control won't work as expected. For expected outcomes for the control we need to utilize Control State property. The Control state is isolated from the View state.

The most effective method to utilize control state property, override the OnInit() function for the control and include a call for the Page.RegisterRequiresControlState() function with the instance of the control to register. At that point override LoadControlState and SaveControlState so as to save the required state data.

Hidden field is a control given by ASP.NET which is utilized to store limited quantities of information on the client. It stores one value for a variable and it is an ideal way when the value of that variable is changing regularly. Hidden field control isn't rendered to the browser and is invisible too. A hidden field goes with each request like a standard control's worth.

Let’s see an example of how to use this hidden field. This would increase the value by 1 on every button click.

The source of the hidden field control is:

<asp:HiddenField ID="HiddenField1" runat="server"  /> 

In the code-behind page:

Protected void Page_Load(object sender, EventArgs e)
{
   if (HiddenField1.Value != NULL)
   {
int val = Convert.ToInt32(HiddenField1.Value) + 1;
    HiddenField1.Value = val.ToString();
Label.Text = val.ToString();
   }
}
protected void Button1_Click(object sender, EventArgs e)
{
  //No Action Button Click
}

View state is another client side state management technique in ASP.NET to store client's information, i.e., in some cases the client needs to protect information briefly after a postback, at that point the view state is the favored route for doing it. It stores information in the produced HTML utilizing the hidden field, not on the server.

View State gives page level state management i.e., as long as the client is on the present page, the state is accessible and the client sidetracks to the following page and the present page state is lost. View State can store any sort of information since it is item type yet it is best not to store complex information because of the requirement for serialization and deserilization on each postback. View state is on by default for all server-side controls of ASP.NET with a property EnableviewState set to true.

Let us see with an example how ViewState is utilized & implemented. In the below example we try to save the count of postbacks on each button click.

It’s a tiny file that is being created by the client's browser and also get stored on the hard disk of that client. It doesn't utilize server memory. For the most part, a cookie is utilized to identify users.

A cookie stores client data. At whatever point a client makes a request for a page the first run through, the server creates a cookie and sends it to the client alongside the mentioned page and the client browser gets that cookie and stores it on the client’s either permanently or temporarily. Whenever the client makes a request for a similar site, either the equivalent or another page, the browser checks the presence of the cookie for that site in the folder. In the event that the cookie exists, it sends that request with the same cookie, else that request is treated as a new request. Let see a sample code to understand how it works:

int postbacks = 0; 
if (Request.Cookies["number"] != null) 
{ 
postbacks = Convert.ToInt32(Request.Cookies["number"].Value) + 1; 
} 
// Generating Response 
else  
{ 
postbacks = 1; 
} 
Response.Cookies["number"].Value = postbacks.ToString();
Result.Text = Response.Cookies["number"].Value;

There are two kinds of cookies created by the client’s browser, which are as follows:

  • Persistence Cookie: Cookies which has an expiry date time is known as persistence cookies. Persistence cookies are permanently stored until the expiry date time which was set. Let us see how to create persistence cookies. There are two ways to create them:

Link: https://www.codeproject.com/Articles/492397/State-Management-in-ASP-NET-Introduction

  • Non-Persistence Cookie: Non-Persistence cookies are not for all time put away on the client customer. It keeps up client data as long as the user accesses the same browser. At the point when the client shuts the browser, the cookie will be disposed of. Non Persistence cookies are helpful for open/public PCs. Let us see how to create non-persistence cookies. There are two ways to create them:

Application state is a server-side state the board procedure. The data put away in the application state is basic for all clients of that specific ASP.NET application and can be accessed from anyplace in the application. It is likewise called the application-level state of the management. Information put away in the application ought to be of little size.

Let’s see how to set & get a value in the application state object:

Following are the Application events on ASP.NET:

There are three events in ASP.NET. The application occasion is written in Global.asax. This document isn't made, of course, it is made expressly by the engineer in the root directory. An application can make more than one Global.asax record yet just the root one is perused by ASP.NET.

  • Application_start: The Application_Start event is raised when an application domain begins.
  • Application_Error: It is raised when an unhandled exception happens, and we can deal with the exception of this event.
  • Application_End: The Application_End event is raised just before an application domain ends as a result of any reason, may IIS server restarting or rolling out certain improvements in an application cycle.

Session Management is a solid system to look after state. By and large session is utilized to store client's data as well as remarkably recognize a client (or state program or browser). The server keeps up the condition of client data by utilizing a session ID. At the point when clients make a request without a session ID, ASP.NET makes a session ID and sends it with each request and response to the same user/client.

Following are the Session Events in ASP.NET:

To deal with a session, ASP.NET gives two events: session_start and session_end that is written in Global.asax in the root directory of the project.

  • Session_Start: The Session_start occasion is raised each time another client makes a request without a session ID, i.e., the new program gets to the application, at that point a session_start occasion raised. We should see Global.asax document.
  • Session_End: The Session_End event is raised when the session closes either in view of a time out or explicitly by utilizing Session.Abandon(). The Session_End event is brought distinctly up for the situation of In proc mode, not in the state server and SQL Server modes.

There are four session storage mechanisms provided by ASP.NET:

  • In Proc mode

In proc mode is the default mode given by ASP.NET. In this mode, session values are put away in the web server's memory (in IIS). On the off chance that there are more than one IIS servers, at that point session values are put away in every server independently on which request has been made. Since the session values are put away in the server, at whatever point server is restarted the session esteems will be lost.

  • State Server mode

This mode could store session in the webserver however out of the application pool. Yet, as a rule if this mode is utilized there will be a different server for putting away sessions, i.e., state server. The advantage is that when IIS restarts the session is accessible. It stores sessions in a different Windows service. For State server session mode, we need to design it unequivocally in the web config record and begin the aspnet_state service.

  • SQL Server mode

Session is put away in a SQL Server database. This sort of session mode is likewise isolated from IIS, i.e., session is accessible even subsequent to restarting the IIS server. This mode is profoundly secure and dependable yet in addition has a burden that there is overhead from serialization and deserialization of session data. This mode ought to be utilized when reliability is of higher importance than performance of application.

  • Custom mode

By and large we ought to lean toward in proc state server mode or SQL Server mode yet on the off chance that you have to store session information utilizing other than these procedures, at that point ASP.NET gives a custom session mode. Thusly we need to keep up everything customized even producing session ID, information store, and furthermore security.

  • Session.Clear():
    • Clears all the session values but doesn't destroy the Session.
    • Removes only the values (content) from the Object.
    • The session with the same key is still alive.
    • Use Session.Clear(): if you don’t want to kill the session but just wants to clear the session-specific data and reinitialize the session.
    • It will not raise the Session_OnEnd event.
  • Abondon():
    • Destroys the whole session object & release all the resources
    • If you do not call the Abandon method explicitly, the server destroys the objects when the session times out.
    • It has no return value and no parameters
    • Abandon raises the Session_OnEnd event request.
    • If a request is made that includes the session identifier for an expired or abandoned session, a new session is started using the same session identifier

ASP.NET Web Parts is a set of controls for creating Websites that enable users to update the content, behavior and appearance of Web pages directly from a browser. The modifications can be applied to all or individual end-users. When users modify pages or controls, those settings can be saved to retain a user's personal setting preferences across future browser sessions. This feature is called personalization. These Web Parts capabilities mean that developers can authorize end-users to personalize any Web application dynamically, without intervention of any developer or administrator. Different Web Parts can share their data with each other.

Web Parts Modes:

  • Normal mode: End users cannot edit & move sections of the page.
  • Edit Mode: End users can edit Web Parts & custom properties on the page.
  • Design Mode: End users can reorder the pages Web Parts in a WebPartZone.
  • Catalog Mode: New Web Parts can be added by the end-user in any WebPartZone on the page.

Utilizing master pages, we can create the common UI components for all the site pages and make a consistent look and feel for the entire site.

  • A Master page offers a format/template for at least one or more web forms.
  • It characterizes placeholders for the content, which can be superseded by the content pages.
  • You would then be able to make individual content pages that contain the content you need to show. At the point when clients demand the content pages, they converge with the master page to create yield that consolidates the format of the master page with the content from the content page
  • A Master page has .master as a file extension
  • Any Master page is distinguished by an exceptional @Master directive <%@Master Language="C#" %>
  • It can have from 1 to many ContentPlaceHolder i.e. can hold multiple content pages

This, along with other NET interview questions for freshers, is a regular feature in NET interviews, be ready to tackle it with the approach mentioned above.

  • Page Level: By using the page directive on each content page to bind it to a master page
  • Application Level: By making a setting in the pages element of the application's Web.config file. All the specified ASP.NET pages (.aspx files) in the application will be automatically bind to a master page.
  • Folder Level: This strategy is used to bind at the application level, except that you make the setting in a Web.config file in one folder only. Here, master-page bindings are applied to all the ASP.NET pages in that folder.
  • config:
    • This is automatically installed when you install Visual Studio. Net.
    • This is also called a machine level configuration file.
    • Only one Machine.config file exists on a server.
    • This file is at the highest level in the configuration hierarchy.The settings of Machine.config file are applied to the whole asp.net application.
  • config:
    • This is automatically created when you create an ASP.Net web application project.
    • This is also called the application-level configuration file.
    • This file inherits the setting from the Machine.config.
    • Web. Config is used for asp.net web projects/web services.
    • The settings made in the Web.config file are applied to that particular web application only.
  • asax:
    • Used to handle application and session-level events and objects for an ASP.NET web site running on an IIS Web Server.
    • Code to handle application events (such as the start and end of an application) resides in Global.asax.
    • Such event code cannot reside in the ASP.NET page or web service code itself, since during the start or end of the application, its code has not yet been loaded (or unloaded).
    • It is also used to declare data that is available across different application requests or across different browser sessions. This process is known as application and session state management
Response.Redirect
Server.Transfer
Browser URL changes
URL does not change
Redirection happens through browser
Redirection happens through a server
Http Request à Browser àWebserver àBrowser
Http Request à Webserver àBrowser
Round trip
No round trip
Cross-server redirection is possible only by using ‘Response.Redirect’ i.e. it allows redirection to internal as well as external websites and website pages.
From www.google.com à www.xyz.com not possible. This redirection not possible because both are on different servers.
For both .aspx & .html
Only for .aspx
It’s a client process
It’s a server process

A staple in NET interview questions and answers, be prepared to answer this one using your hands-on experience.

  • A Hyperlink just redirects to a given URL identified by "NavigateURL" property.
  • Link Button does not have Navigate URL instead it has “Postback URL” property
  • LinkButton causes a postback to the same page but it doesn't redirect to a given URL
  • HyperLink doesn't have the OnClick event. Link Button has Onclick event
  • if you need to do any operation with data that's on the page you will have to use a LinkButton (or a Button), but if you just need to redirect the user to somewhere else go for an HyperLink
Custom Controls
User Controls
Compiled into their own assembly(.dll)
Compiled into the web application assembly
Therefore, these can be added to the toolbox and can be used like any other existing controls.
Therefore, these cannot be added to the toolbox
Drag n drop from toolbox
Drag n drop from solution explorer.
.ascx file is created for each project in the solution
Complex to create.
Easier to create just like a web form.
They don’t have a designer. So, everything from a declaration of controls to rendering them has to be written through code.
They have designer associated with them, which makes it easier to create them.
Multiple copies of custom controls are not required in the projects.
Every web app project requires its own copy of user control

This, along with other NET interview questions for freshers, is a regular feature in NET framework interviews, be ready to tackle it with the approach mentioned.

1. Using the FindControl() method

  • using System;
  • using System.Collections.Generic;
  • using System.Linq;
  • using System.Web;
  • using System.Web.UI;
  • using System.Web.UI.WebControls;
  • public partial class FindControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
     //Define Label Control and Fetch the control of MASTER PAGE
     Label lbl = (Label)Page.Master.FindControl("lblFirstName");
     //Set the value to CONTENT PAGE label control.
     lblFindControlUserName.Text = "Value Received in Content Page : "+lbl.Text;
}
}

2. Without using the FindControl() method

Yes, by casting the Master to your MasterPage as shown in the below code sample:

protected void Page_Load(object sender, EventArgs e)

{
    MyMasterPage MP = this.Master;
    MP.MyTextBox.Text = "Text Box Found";
}

Description

.NET Framework is a general-purpose development platform developed by Microsoft. It runs primarily on Microsoft Windows operating system and used for any kind of app or workload. It comprises of a comprehensive class library called Framework Class Library (FCL), provides language interoperability over a wide range of programming languages. It is considered to consist of 70,000 Classes in libraries. The programs which are written for .Net Framework are executed in a software environment known as Common Language Runtime (CLR). CLR is an application virtual machine, one that offers services like security, memory management, and exception handling. The computer code written using .Net Framework is known as ‘Managed code’. Together, FCL and CLR form the .Net Framework.

.Net Framework is used to provide key abilities for designing high-quality apps that comprises of automatic memory management and support for modern programming languages. .Net Framework’s CLR offers memory management to support an application. It consists of libraries for specific sections of application development like ASP.NET for web applications, ADO.NET for data access, and Windows Communication Foundation for service-oriented applications. You can learn more about these with a .Net Framework Course.   

Because .Net Framework offers a wide range of facilities, it remains as the best choice for any client who wants to develop their application. Software Developers who know .Net Framework are always in demand, also because of the fact that Microsoft is the market leader in the software industry. So are a lot of vacancies for .Net Framework developers. The fields that these developers can work in are as follows:

  • Next generation mobile apps
  • Business functions
  • Gaming
  • Communication
  • Cross-platform
  • Multi-tiered software applications

As per payscale.com data, the average salary for entry-level .Net Developers is $71,115, going as high as $96,879 per annum, while for experienced .Net developers, the average salary is $96,035 per annum, going as high as Rs 1,204,356. The major companies hiring .Net developers are Microsoft Corp, HP, Google, Intel, Amazon.com Inc, and Thomson Reuters.

So, as you can see, there are plenty of job opportunities for skilled .Net Framework Developers. It is just that you need a proper form of guidance and key tips and suggestions to answer .Net Framework interview questions and crack any .Net Framework interview. Here is where we come to your rescue with training for web development.

Our experts have systematically compiled a set of 14 .Net Framework interview. questions that will not only guide you to know how you will answer any possible question in a clear manner and with self-assurance but also give you an edge over the other candidates to excel in any PL/SQL job interview.

Moreover, this set of 14 .Net Framework interview questions and answers will also help experienced .Net Developers who want to take the next higher step in their careers.

So wait no longer! Consult our .Net Framework interview questions and answers to crack any .Net Framework job interview and grab the dream job that you have been longing for.

All the best!

Read More
Levels