Beginner Level
Beginner Level
0 Interview Questions –
Beginner Level
The Q&A mentioned over here have been taken from forums, my colleagues and my
own experience of conducting interviews. I have tried to mention the contributor
wherever possible. If you would like to contribute or you think that a credit for a
contribution is missing somewhere, kindly contact me and I will do the needful.
What is ASP.NET?
Microsoft ASP.NET is a server side technology that enables programmers to build
dynamic Web sites, web applications, and XML Web services. It is a part of the .NET
based environment and is built on the Common Language Runtime (CLR) . So
programmers can write ASP.NET code using any .NET compatible language.
What are the differences between ASP.NET 1.1 and ASP.NET 2.0?
A comparison chart containing the differences between ASP.NET 1.1 and ASP.NET 2.0
can be found over here.
Which is the latest version of ASP.NET? What were the previous versions
released?
The latest version of ASP.NET is 2.0. There have been 3 versions of ASP.NET released
as of date. They are as follows :
ASP.NET 1.0 – Released on January 16, 2002.
ASP.NET 1.1 – Released on April 24, 2003.
ASP.NET 2.0 – Released on November 7, 2005.
Additionally, ASP.NET 3.5 is tentatively to be released by the end of the 2007.
Explain the Event Life cycle of ASP.NET 2.0?
The events occur in the following sequence. Its best to turn on tracing(<% @Page
Trace=”true”%>) and track the flow of events :
PreInit – This event represents the entry point of the page life cycle. If you need to
change the Master page or theme programmatically, then this would be the event to
do so. Dynamic controls are created in this event.
Init – Each control in the control collection is initialized.
Init Complete* - Page is initialized and the process is completed.
PreLoad* - This event is called before the loading of the page is completed.
Load – This event is raised for the Page and then all child controls. The controls
properties and view state can be accessed at this stage. This event indicates that the
controls have been fully loaded.
LoadComplete* - This event signals indicates that the page has been loaded in the
memory. It also marks the beginning of the rendering stage.
PreRender – If you need to make any final updates to the contents of the controls
or the page, then use this event. It first fires for the page and then for all the
controls.
PreRenderComplete* - Is called to explicitly state that the PreRender phase is
completed.
SaveStateComplete* - In this event, the current state of the control is completely
saved to the ViewState.
Unload – This event is typically used for closing files and database connections. At
times, it is also used for logging some wrap-up tasks.
The events marked with * have been introduced in ASP.NET 2.0.
You have created an ASP.NET Application. How will you run it?
With ASP.NET 2.0, Visual Studio comes with an inbuilt ASP.NET Development Server
to test your pages. It functions as a local Web server. The only limitation is that
remote machines cannot access pages running on this local server. The second
option is to deploy a Web application to a computer running IIS version 5 or 6 or 7.
Explain the AutoPostBack feature in ASP.NET?
AutoPostBack allows a control to automatically postback when an event is fired. For
eg: If we have a Button control and want the event to be posted to the server for
processing, we can set AutoPostBack = True on the button.
How do you disable AutoPostBack?
Hence the AutoPostBack can be disabled on an ASP.NET page by disabling
AutoPostBack on all the controls of a page. AutoPostBack is caused by a control on
the page.
What are the different code models available in ASP.NET 2.0?
There are 2 code models available in ASP.NET 2.0. One is the single-file page and the
other one is the code behind page.
Which base class does the web form inherit from?
Page class in the System.Web.UI namespace.
Which are the new special folders that are introduced in ASP.NET 2.0?
There are seven new folders introduced in ASP.NET 2.0 :
\App_Browsers folder – Holds browser definitions(.brower) files which identify the
browser and their capabilities.
\App_Code folder – Contains source code (.cs, .vb) files which are automatically
compiled when placed in this folder. Additionally placing web service files generates a
proxy class(out of .wsdl) and a typed dataset (out of .xsd).
\App_Data folder – Contains data store files like .mdf (Sql Express files), .mdb,
XML files etc. This folder also stores the local db to maintain membership and role
information.
\App_GlobalResources folder – Contains assembly resource files (.resx) which
when placed in this folder are compiled automatically. In earlier versions, we were
required to manually use the resgen.exe tool to compile resource files. These files
can be accessed globally in the application.
\App_LocalResources folder – Contains assembly resource files (.resx) which can
be used by a specific page or control.
\App_Themes folder – This folder contains .css and .skin files that define the
appearance of web pages and controls.
\App_WebReferences folder – Replaces the previously used Web References
folder. This folder contains the .disco, .wsdl, .xsd files that get generated when
accessing remote web services.
Explain the ViewState in ASP.NET?
Http is a stateless protocol. Hence the state of controls is not saved between
postbacks. Viewstate is the means of storing the state of server side controls
between postbacks. The information is stored in HTML hidden fields. In other words,
it is a snapshot of the contents of a page.
You can disable viewstate by a control by setting the EnableViewState property to
false.
What does the EnableViewState property signify?
EnableViewState saves the state of an object in a page between postbacks. Objects
are saved in a Base64 encoded string. If you do not need to store the page, turn it
off as it adds to the page size.
There is an excellent article by Peter Bromberg to understand Viewstate in depth.
Explain the ASP.NET Page Directives?
Page directives configure the runtime environment that will execute the page. The
complete list of directives is as follows:
@ Assembly - Links an assembly to the current page or user control declaratively.
@ Control - Defines control-specific attributes used by the ASP.NET page parser and
compiler and can be included only in .ascx files (user controls).
@ Implements - Indicates that a page or user control implements a specified .NET
Framework interface declaratively.
@ Import - Imports a namespace into a page or user control explicitly.
@ Master - Identifies a page as a master page and defines attributes used by the
ASP.NET page parser and compiler and can be included only in .master files.
@ MasterType - Defines the class or virtual path used to type the Master property of
a page.
@ OutputCache - Controls the output caching policies of a page or user control
declaratively.
@ Page - Defines page-specific attributes used by the ASP.NET page parser and
compiler and can be included only in .aspx files.
@ PreviousPageType - Creates a strongly typed reference to the source page from
the target of a cross-page posting.
@ Reference - Links a page, user control, or COM control to the current page or user
control declaratively.
@ Register - Associates aliases with namespaces and classes, which allow user
controls and custom server controls to be rendered when included in a requested
page or user control.
This list has been taken from here.
Explain the Validation Controls used in ASP.NET 2.0?
Validation controls allows you to validate a control against a set of rules. There are 6
different validation controls used in ASP.NET 2.0.
RequiredFieldValidator – Checks if the control is not empty when the form is
submitted.
CompareValidator – Compares the value of one control to another using a
comparison operator (equal, less than, greater than etc).
RangeValidator – Checks whether a value falls within a given range of number, date
or string.
RegularExpressionValidator – Confirms that the value of a control matches a pattern
defined by a regular expression. Eg: Email validation.
CustomValidator – Calls your own custom validation logic to perform validations that
cannot be handled by the built in validators.
ValidationSummary – Show a summary of errors raised by each control on the page
on a specific spot or in a message box.
How do you identify that the page is post back?
By checking the IsPostBack property. If IsPostBack is True, the page has been posted
back.
Every application within an application pool shares the same worker process.
Because each worker process operates as a separate instance of the worker process
executable, W3wp.exe, the worker process that services one application pool is
separated from the worker process that services another. Each separate worker
process provides a process boundary so that when an application is assigned to one
application pool, problems in other application pools do not affect the application.
This ensures that if a worker process fails, it does not affect the applications running
in other application pools.
Use multiple application pools when you want to help ensure that applications and
Web sites are confidential and secure. For example, an enterprise organization might
place its human resources Web site and its finance Web site on the same server, but
in different application pools. Likewise, an ISP that hosts Web sites and applications
for competing companies might run each companys Web services on the same
server, but in different application pools. Using different application pools to isolate
applications helps prevent one customer from accessing, changing, or using
confidential information from another customers site.
In HTTP.sys, an application pool is represented by a request queue, from which the
user-mode worker processes that service an application pool collect the requests.
Each pool can manage requests for one or more unique Web applications, which you
assign to the application pool based on their URLs. Application pools, then, are
essentially worker process configurations that service groups of namespaces.
Multiple application pools can operate at the same time. An application, as defined by
its URL, can only be served by one application pool at any time. While one
application pool is servicing a request, you cannot route the request to another
application pool. However, you can assign applications to another application pool
while the server is running.