ASP.NET
interview questions posted by By Nishant Kumar
Question - Define assembly.
Answer - An assembly is the primary
unit of a .NET application. It
includes an assembly manifest that
describes the assembly.
Question - Define .NET executable.
Answer - It exists as an IL file(Assembly), it is checked
against the security policy on load, gets loaded into memory and
then JIT compiled into native binary code.
Question - Explain .net architecture.
Answer -
The ordering starts from the bottom.
Physical Hardware Machine
(Intel Pentium, apple macintosh)
Operating System (Microsoft
Windows, Linux etc)
Common Language Runtime
(CLR)
Framework Class Library
(FCL)
ADO.Net and XML
Library
WinForm, Web Application,
Web Serivces (Managed Application)
Question - Name the ASP.NET objects.
Answer - Request,Response,Server,Session,
andApplication.
Question - Briefly describe the life cycle of ASP.NET web form.
Answer -
Page_Init, Page_Load,Page_PreRender,
Page_Unload,
Page_disposed, andPage_Error.
Question - Define .NET Framework base class library.
Answer -
It organizes code into namespaces and contain
types and additional namespaces related to common functionality.
Question - Define Variable Types.
Answer
- Variable types can be of two types namely value types
or reference types.
Value type contains all the
data associated with that type.
Value types remain empty on
declaration until they are assigned a value.
Reference
type contains a pointer to an instance of an object of that type.
Reference
type must be instantiated after declaration to create the object.
You
can declare and instantiate reference
type in single step.
Question - Define User-defined types.
Answer
- It can be in the form of classes and structures.
Both
class and structure can have members(fields, properties, methods, or events).
Classes
are reference types, and structures are value types.
Both
type must use the New (new
) keyword for instantiation.
Question - Define methods.
Answer
- It is used to perform the data manipulation.
It can return a value.
Methods
that return values are called Functions in VB.net.
Non-value-returning
methods are called Sub.
Methods can have
parameters.
Parameters are passed by
value by default.
Pass
parameters by reference with the ByRef keyword
Question - Define abstract class.
Answer
- Abstract class cannot be instantiated, it has to be
inherited.
The methods in abstract
class can be overriden in the child class.
Question - Difference between Response.Write()
and Response.Output.Write().
Answer
- Response.Output.Write() allows you to write formatted
output.
Question - Define a Process, Session and Cookie.
Answer -
Process - Instance of the application.
Session - Instance of the user accessing the application.
Cookie - Used for storing small amount of data on client machine.
Question - When is ViewState available during the page
processing cycle?
Answer -
ViewState is available after the Init() and before the Page_Load().
Question - Explain serialization in ASP.NET?
Answer -
Serialization is a process of converting an object into a stream of bytes. .Net
has 2 serializers namely XMLSerializer and SOAP/BINARY Serializer.
Serialization is maily used in the concept of .Net Remoting.
Question - What is a Constructor?
Answer - It is the
first method that are called on instantiation of a type.
It provides way to set default values for data before the object is
available for use.
Performs other necessary functions before the object is available for
use.
Question - What is a Destructor?
Answer -
It is called just before an object is destroyed.
It can be used to run clean-up code.
You cannot
control when a destructor is called since object clean up by common language
runtime.
Question - Explain how a web application works.
Answer - A
web application resides in the server and serves the client™s requests over
internet. The client access the web page using browser from his machine. When a
client makes a request, it receives the result in the form of HTML which are
interpreted and displayed by the browser.
A web application on the
server side runs under the management of Microsoft Internet Information
Services (IIS). IIS passes the request received from client to the application.
The application returns the requested result in the form of HTML to IIS, which
in turn, sends the result to the client.
Question - Explain the different parts that constitute ASP.NET application.
Answer - Content, program logic and configuration file
constitute an ASP.NET application.
Content files
Content files include static text, images and can include elements from
database.
Program logic
Program logic files exist as DLL file on the server that responds to the user
actions.
Configuration file
Configuration file offers various settings that determine how the application
runs on the server.
Question - Describe the sequence of action takes place on the server
when ASP.NET application starts first time?
Answer - Following are the
sequences:
IIS starts ASP.NET worker process>> worker process loads assembly in the
memory>>IIS sends the request to the assembly>>the assembly
composes a response using program logic>> IIS returns the response to the
user in the form of HTML.
Question - Explain the components of web form in ASP.NET.
Answer - Server controls
The server controls are Hypertext Markup Language (HTML) elements that include
a runat=server attribute. They provide automatic state management and
server-side events and respond to the user events by executing event handler on
the server.
HTML controls.
These controls also respond to the user events but the events processing happen
on the client machine.
Data controls
Data controls allow to connect to the database, execute command and retrieve
data from database.
System components
System components provide access to system-level events that occur on the
server.
Question - Describe in brief the .NET Framework and its components.
Answer - .NET Framework provides
platform for developing windows and web software. ASP.NET is a part of .Net
framework and can access all features implemented within it that was formerly
available only through windows API. .NET Framework sits in between our
application programs and operating system.
The .Net Framework has two main components:
.Net Framework Class Library: It provides common types such as data types and
object types that can be shared by all .Net compliant language.
The Common language Runtime: It provides services like type safety, security,
code execution, thread management, interoperability services.
Question - What is an Assembly? Explain its parts?
Answer - An assembly exists as a .DLL
or .EXE that contains MSIL code that is executed by CLR. An assembly contains
interface and classes, it can also contain other resources like bitmaps, files
etc. It carries version details which are used by the CLR during execution. Two
assemblies of the same name but with different versions can run side-by-side
enabling applications that depend on a specific version to use assembly of that
version. An assembly is the unit on which permissions are granted. It can be
private or global. A private assembly is used only by the application to which
it belongs, but the global assembly can be used by any application in the
system.
The parts of an assembly are:
Assembly Manifest - It contains name, version, culture, and information about
referenced assemblies.
Type metadata - It contains information about types defined in the assembly.
MSIL - MSIL code.
Resources - Files such as BMP or JPG file or any other files required by
application.
Question - Define Common Type System.
Answer - .Net allows developers to write program logic in
at least 25 languages. The classes written in one language can be used by other
languages in .Net. This service of .Net is possible through CTS which ensure
the rules related to data types that all language must follow. It provides set
of types that are used by all .NET languages and ensures .NET language type
compatibility.
Question - Define Virtual folder.
Answer - It is the folder that contains web applications.
The folder that has been published as virtual folder by IIS can only contain
web applications.
Question - What are the ways of preserving data on a Web Form in
ASP.NET?
ASP.NET has introduced view state to preserve data between postback events.
View state can't avail data to other web form in an application. To provide
data to other forms, you need to save data in a state variable in the
application or session objects.
Question - Define application state variable and session state variable.
These objects provide two levels of scope:
Application State
Data stored in the application object can be shared by all the sessions of the
application. Application object stores data in the key value pair.
Session State
Session State stores
session-specific information and the information is visible
within the session only. ASP.NET creates unique sessionId for
each session of the application. SessionIDs are maintained
either by an HTTP cookie or a modified URL, as set in the
application's configuration settings. By default, SessionID
values are stored in a cookie.