ASP.NET Interview Questions and Answers

1. What is ASP.NET?

ASP.NET is a web application framework developed by Microsoft which is open source & runs on server side. It allows programmers to develop dynamic web pages & web services as well using HTML, Javascript, CSS, C# etc. It is the successor to Microsoft’s Active Server Pages (ASP) technology.

2. How does ASP.NET differ from PHP?

Firstly, ASP.NET is always compiled whereas PHP is usually interpreted but it can be compiled using commercial compilers. Secondly, websites developed through ASP.NET can be hosted only in windows servers whereas websites developed through PHP can be hosted in windows as well as linux servers.

3. How does ASP.NET differ from Classic ASP?

Firstly, ASP.NET is always compiled as it uses .Net language like C# whereas ASP is interpreted as it uses VBScript. Secondly, in ASP error handling is very poor whereas in ASP.NET tools like Microsoft Visual Studio used for debugging help in error handling. Thirdly, ASP does not have built in support for xml whereas ASP.NET has full support for xml.

4. What is Common Language Runtime (CLR)?

CLR is used to manage the execution of .NET programs. It uses just-in-time which converts compiled code into machine code and then executes it. It has 4 primary functions which are Garbage collection, Code Access Security(CAS), Code Verification(CV) and Intermediate Language(IL) to native translation.

5. Explain IL, CTS, CLS and JIT.

  • IL(Intermediate Language)- It is a lowest level programming language designed for usage by compilers. During runtime just-in-time compiler converts IL into machine code and then executes it.
  • CTS(Common Type System)-CTS is a standard which defines how types are declared, used and managed in the common language runtime. It supports 5 types i.e. classes, structures, enumerations, interfaces and delegates.
  • CLS (Common Language Specification)- It forms a set of rules which every language has to follow those run under .NET framework. It is a subset of CTS(Common Type System).
  • JIT(Just-in-time)- JIT compiles the IL (Intermediate Language)code to Machine code before execution and then saves this transaction in memory.

6. What are the different types of JIT?

Different Types of JIT are:
A) Pre-JIT - Complies complete source code into native code in a single cycle at the time of deployment.
B) Econo-JIT - Complies those methods that are called at runtime. They are removed when they are not required anymore.
C) Normal-JIT - Complies those methods that are called at runtime and then they are stored in cache. Next time when the same methods are called, compiled code will be taken from cache.

7. Define a Managed Code.

Managed code is written in any high level programming language like C#, J# etc. Which is used with .NET framework. It will execute inside the environment of Common Language Runtime (CLR) i.e. .NET runtime. Note that all Intermediate Language (IL) are managed code. If you want to use any third party software i.e. VC++ etc. they are unmanaged code.

8. Explain the working of a web application.

A web application resides in the server and responds to the client's requests over internet. When a client accesses the web page using browser from his machine and makes a request, it receives the response in HTML form which is displayed by the browser. Microsoft Internet Information Services (IIS) is required to run this web application on the server side. IIS sends the request of the client to the application. The application returns the requested result to IIS in HTML form then IIS sends this result to the client.

9. Explain serialization and deserialization.

Serialization is an object conversion into a stream of bytes and deserialization is creation of an object from a stream of bytes.

10. What are the application and session event handlers in ASP.NET ?

1.Application_Start - Triggers when the first user visits a page of the application or 2.first resource is requested from the server.
3.Application_End - Triggers when there are no more users of the application.
4.Application_BeginRequest - Triggers at the beginning of each request to the server.
5.Application_EndRequest - Triggers at the end of each request to the server.
6.Session_Start - Triggers when a new user visits.
7.Session_End - Triggers when the users stop requesting pages and their session times out.