Accreditation Bodies
Accreditation Bodies
Accreditation Bodies
Supercharge your career with our Multi-Cloud Engineer Bootcamp
KNOW MORE.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.
Filter By
Clear all
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 :
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:
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
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:
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.
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.
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.
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:
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.
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:
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:
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:
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 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 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).
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:
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:
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.
Add, Remove and View Assemblies in the GAC
gacutil /i “C:\someFolder\SomeAssembly.dll”
Note: full path must be mentioned so that the tool gets the correct assembly.
gacutil /u SomeAssembly
Note: Only an assembly name is required. This command will remove all versions of the assembly.
gacutil / u SomeAssembly, Version = 1.1.1.1
gacutil / l
Namespace
Assembly
.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:
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 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.
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 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.
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 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 -
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 :
All windows executable files and assemblies follow the Portable executable file formats.
.NET PE file format consists of four parts:
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,
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;
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.
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:
Dispose | Finalize |
---|---|
It is used to free unmanaged items like file or Database connection | It 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 interface | It belongs to Object class |
Called from user code and the class which is implementing dispose method | Only 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 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 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.
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
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:
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:
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:
a) User sends a solicitation to the IIS
b) An occasion of the ApplicationManager class is made, which is the Application Domain that the solicitation is handled in.
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.
f) Once 'HttpApplication' is made, it begins preparing demands. It experiences following 4 stages:
This is one of the most frequently asked ASP.NET framework interview questions and answers for freshers in recent times.
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:
Server Side
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:
Link: https://www.codeproject.com/Articles/492397/State-Management-in-ASP-NET-Introduction
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.
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.
There are four session storage mechanisms provided by ASP.NET:
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.
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.
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.
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.
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:
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.
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.
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.
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
{ 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"; }
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 :
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:
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
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:
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.
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.
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.
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:
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.
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:
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:
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:
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 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 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).
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:
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:
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.
Add, Remove and View Assemblies in the GAC
gacutil /i “C:\someFolder\SomeAssembly.dll”
Note: full path must be mentioned so that the tool gets the correct assembly.
gacutil /u SomeAssembly
Note: Only an assembly name is required. This command will remove all versions of the assembly.
gacutil / u SomeAssembly, Version = 1.1.1.1
gacutil / l
Namespace
Assembly
.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:
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 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.
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 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.
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 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 -
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 :
All windows executable files and assemblies follow the Portable executable file formats.
.NET PE file format consists of four parts:
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,
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;
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.
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:
Dispose | Finalize |
---|---|
It is used to free unmanaged items like file or Database connection | It 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 interface | It belongs to Object class |
Called from user code and the class which is implementing dispose method | Only 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 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 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.
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
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:
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:
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:
a) User sends a solicitation to the IIS
b) An occasion of the ApplicationManager class is made, which is the Application Domain that the solicitation is handled in.
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.
f) Once 'HttpApplication' is made, it begins preparing demands. It experiences following 4 stages:
This is one of the most frequently asked ASP.NET framework interview questions and answers for freshers in recent times.
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:
Server Side
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:
Link: https://www.codeproject.com/Articles/492397/State-Management-in-ASP-NET-Introduction
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.
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.
There are four session storage mechanisms provided by ASP.NET:
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.
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.
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.
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.
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:
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.
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.
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.
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
{ 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"; }
.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:
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!
Submitted questions and answers are subjecct to review and editing,and may or may not be selected for posting, at the sole discretion of Knowledgehut.
Get a 1:1 Mentorship call with our Career Advisor
By tapping submit, you agree to KnowledgeHut Privacy Policy and Terms & Conditions