What methods are fired during the page load?

colonteeΛογισμικό & κατασκευή λογ/κού

4 Νοε 2013 (πριν από 4 χρόνια και 8 μήνες)

121 εμφανίσεις


What’s the difference between Response.Write() andResponse.Output.Write()?

Response.Output.Write() allows you to write formatted output.


What methods are fired during the page load?


when the page is instantiated


when the page is
loaded into server memory


the brief moment before the page is displayed to the user as HTML


when page finishes loading.


When during the page processing cycle is ViewState available?

After the Init() and before the Page_Load(), or
OnLoad() for a control.


What namespace does the Web page belong in the .NET Framework class hierarchy?



Where do you store the information about the user’s locale?

CodeBehind is relevant to Visual Studio.NET only.


What’s the differen
ce between Codebehind="MyCode.aspx.cs"

CodeBehind is relevant to Visual Studio.NET only.


What is the Global.asax used for?

The Global.asax (including the Global.asax.cs file) is used to implement application and session level


What are the Application_Start and Session_Start subroutines used for?

This is where you can set the specific variables for the Application and Session objects.


Whats an assembly?

Assemblies are the building blocks of the .NET framework;


Whats MSIL
, and why should my developers need an appreciation of it if at all?

MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to
MSIL. MSIL also allows the .NET Framework to JIT compile the assembly on the installed co


Which method do you invoke on the DataAdapter control to load your generated dataset
with data?

The Fill() method.


Can you edit data in the Repeater control?

No, it just reads the information from its data source


Which template must you provide
, in order to display data in a Repeater control?



Name two properties common in every validation control?

ControlToValidate property and Text property.


What base class do all Web Forms inherit from?

The Page class.


What is the difference between Server.Transfer and Response.Redirect? Why would I
choose one over the other?

Server.Transfer transfers page processing from one page directly to the next page without making a
trip back to the client's browser. This p
rovides a faster response with a little less overhead on
the server. Server.Transfer does not update the clients url history list or current url.
Response.Redirect is used to redirect the user's browser to another page or site. This performas a
trip back t
o the client where the client's browser is redirected to the new page. The user's browser
history list is updated to reflect the new address


What is ViewState?

ViewState allows the state of objects (serializable) to be stored in a hidden field on the page
ViewState is transported to the client and back to the server, and is not stored on the server or any
other external source. ViewState is used the retain the state of server
side objects between


What is the lifespan for items stored in ViewSt

Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same


What does the "EnableViewState" property do? Why would I want it on or off?

It allows the page to save the users input on a form across post
backs. It saves the server
values for a given control into ViewState, which is stored as a hidden value on the page before
sending the page to the clients browser. When the page is posted back to the server the server
control is recreated with the sta
te stored in viewstate.


What are the different types of Session state management options available with

ASP.NET provides In
Process and Out
Process state management. In
Process stores the session
in memory on the web server. This requires the

a "sticky
server" (or no load
balancing) so that the
user is always reconnected to the same web server. Out
Process Session state management
stores data in an external data source. The external data source may be either a SQL Server or a
State Server s
ervice. Out
Process state management requires that all objects stored in session
are serializable.

ASP.NET 3.5 Interview Questions & Answers :

1. Explain the life cycle of an ASP .NET page.?

Following are the events occur during ASP.NET Page Life






6)Control Events






Among above events Page_Render is the only event which is raised by page.

So we can't
write code for this event.

2. how does the cookies work in asp.net?

we know Http is an state
less protocol which is required for interaction between clinet and
server .

so there is an need to remeber state of request raised by an

web brows

so that

web server

can recognize you have already previously visited or not.

There are two types of

state management


a) Client side

state management

b) Server

side statemanagement

Using cookies comes under clinet side statemanagement .I
n HttpResponse we write

Cookie containing sessionId and other information within it.

when a browser made a request to the

web server

the same cookie is sent to the server
where server recognize the session id and get other information stored to it previo

3. What is Ispostback method in ASP.Net? Why do we use that??

Basically Post back is an action performed by a interactive Webpage. When it goes to the
server side for a non
client Operation Server again posts it back to the client and hence the



will not allow the page to post back again n again bcoz it reduces

the performance.

4. Can User Control be stored in library?.

I will say "NO"

there are 3 types of controls:

1) User Control

2) Custom Control

3) Web parts

can reuse User control in the current project in which you have built it, but you can't
move it to other project as unless you just copy paste the same file there and make the
changes for that project ( which violets the concept of library).

but custom co
ntrol can be shared between projects. and you can precompile them even as a
dll, so this means you can use them in library of any type.

5. what is the difference between application state and caching?


Object and Cached Object both falls unde
r Server side State Management.


object resides in InProc i.e. on the same server where we hosted


Cache Object resides on server side/ DownStream/Client Side.


Object will be disposed once


will stop.

he Object can be disposed using Time based cache dependency.

Only one user can access


Object at a time hence we have to lock it every time
we modify it.

6. what is boxing and unboxing?


is what happens when a value
type object is assig
ned to a reference
type variable.


is what happens when a reference
type variable is assigned to a value

7. What are the uses of Reflection??


is a concept using which we can

1) Load assemblies dynamically

2) Invoke


at runtime

3) Retriving type information at runtime.

8. What is the use of AutoWireup in asp.net?

AutoEventWireup attribute is used to set whether the


needs to be automatically
generated or not.

In the case where AutoEventWireup attribute is
set to false (by default) event handlers are
automatically required for Page_Load or Page_Init. However when we set the value of the
AutoEventWireup attribute to true the ASP.NET runtime does not require


to specify
event handlers like Page_Load or P

9. what events will occur when a page is loaded?

Below are the


occures during page load.

1) Page_PreInit

2) Page_Init

3) Page_InitComplete

4) Page_PreLoad

10. Where is the View state Data stored?

ViewState data is stored in the hidden

field. When the page is submitted to the server the
data is sent to the server in the form of hidden fields for each control. If th viewstate of the
control is enable true the value is retained on the post back to the client when the page is
post backed.

11. What is the difference between custom web user control and a custom web
server control?

Web User Control:

1) Easy to Create.

2) It Can be used inside the same Application.(To use it in other application we need to add
it to that project.)

3) It Can t
ake advantage of Caching Technique.

Web Server Control:

1) Bit tuff to create as compare to User Control.

2) Easy to use.

3) Can be added to ToolBox.

12. Where do the Cookie State and Session State information be stored?

Cookie Information will be store
d in a txt file on client system under a

folder named Cookies. Search for it in your system you will find it.

Coming to Session State

As we know for every process some default space will be allocated by OS.

In case of InProc Session Info will be stored in
side the process where our

application is running.

In case of StateServer Session Info will be stored using ASP.NET State Service.

In case of SQLServer Session info will be stored inside Database. Default DB

which will be created after running InstallSQL
State Script is ASPState.

13. What is the difference between adding reference in solution Explorer and
adding references by USING ?

Adding reference in solution


is used to add the DLL for that project for reference
only. If you want to utilize tha
t DLL methods/functions in our aspx.cs/.cs file etc you must
write using that nameclass library name in file.

14. What are the different types of sessions in ASP.Net? Name them.?



can be achieved in two ways



is again two types

1)State Server

2)SQL Server



1) Faster as session resides in the same process as the application

2) No need to serialize the data


1) Will degrade the performance of the application if large chunk of data is stored

2) On restart of IIS all the Session info will be lost

State Server


1) Faster then

SQL Server



2) Safer then InProc. As IIS restart

won't effect the session data


1) Data need to be serialized

2) On restart of ASP.NET
State Service session info will be lost

3)Slower as compared to InProc

SQL Server


1) Reliable and Durable

2) IIS and ASP.NET State Service

restart won't effect the session data

3) Good place for storing large chunk of data


1) Data need to
be serialized

2) Slower as compare to InProc and State Server

3)Need to purchase Licensed

version of

SQL Serve

15. How do you design a website with multilingual support in ASP.NET?

Multilingual website can be created using Globalization and Localization.

Using Globalization we change the Currency Date Numbers etc to Language Specific Format.

To change the string which is there in the label button etc to language specific string we use

In Localization we have to create different Resource file
s for different languages.

During this process we use some classes present in System.Resources System.Globalization
System.Threading namespaces.

16. What is caching? What are different ways of caching in ASP.NET?


is a technique of persisting the d
ata in memory for immediate access to requesting
program calls. This is considered as the best way to enhance

the performance

of the


is of 3 types:




Caches the whole page.




Caches a part of the page




Caches the data

17. What is meant by 3
tier architecture.

We generally split our


into 3



( Where we keep all web forms Master Pages and User Controls).



(Where we keep business logic).
e.g Code related to manipulating data
Custom Exception classes Custom Control classes Login related code if any etc. etc.

Data Access


(Where we keep code used to interact with DB). e.g. We can have the
methods which are using SQL Helper (Applicatio


18. Explain the basic functionality of garbage collector?

Garbage Collector in .Net Framework is used for Automatic Memory Management i.e. it is
collect all unused memory area and give to application. system.gc.collect() is a method for
the memory. But remember one think it is only an request i.e. we can't explicitly
release the memory by using system.gc.collect().

19. What is the difference between mechine.config and web.config?


is a system level configuration i.e it is ap
plied on all


in o/s that
the configuration is set where as in web.config

it is applicable to only one


each asp.net webapplication

will contain atleast on web.config


20. How can exception be handled with out the use of try

using Exception Management application block



Application_error objects

21. What is the difference between Response.Redirect and Server.Transfer.


transfers page processing from one page directly to the next page without
making a round
trip back to the client's browser. This provides a faster


with a little
less overhead on the


does not update the clients url history list or
current url.


is used toredirect

the user's browse
r to another page or site. This
performs a trip back to the client where the client's browser is redirected to the new page.
The user's browser history list is updated to reflect the new address.

22. Where the assembly is stored in asp.net?.




in application / bin directory and public are


in GAC.

23. How we implement Web farm and Web Garden concept in ASP.NET?.

A web farm is a multi
server scenario. So we may have a server in each state of US. If the
load on one server is in
excess then the other servers step in to bear the brunt.

How they bear it is based on various models.

1. RoundRobin. (All servers share load equally)

2. NLB (economical)

3. HLB (expensive but can scale up to 8192 servers)

4. Hybrid (of 2 and 3).

5. CLB (Co
mponent load balancer).

A web garden is a multi
processor setup. i.e. a single server (not like the multi server

How to implement webfarms in .Net:

Go to web.config and

Here for mode you have 4 options.

a) Say mode inproc (non web farm but fast whe
n you have very few customers).

b) Say mode StateServer (for webfarm)

c) Say mode SqlServer (for webfarm)

Whether to use option b or c depends on situation. StateServer is faster but SqlServer is
more reliable and used for mission critical applications.

w to use webgardens in .Net:

Go to web.config and

Change the false to true. You have one more attribute that is related to webgarden in the
same tag called cpuMask.

24. Is there any limit for query string? means what is the maximum size?..

Servers should b
e cautious about depending on URI lengths above 255 bytes because some
older client or proxy implementations may not properly support these lengths.

Query string

length depends on browser compatability

IE supports upto 255

Firefox supports upto 4000

. What is the exact purpose of http handlers?

ASP.NET maps HTTP requests to HttpHandlers. Each HttpHandler enables processing of
individual HTTP URLs or groups of URL extensions within an application. HttpHandlers have
the same functionality as ISAPI exten
sions with a much simpler programming model


1.Default HttpHandler for all ASP.NET pages
>ASP.NET Page Handler (*.aspx)

2.Default HttpHandler for all ASP.NET service pages
>ASP.NET Service Handler (*.asmx)

An HttpHandler can be either synchronous or asy
nchronous. A synchronous handler does
not return until it finishes processing the HTTP request for which it is called. An
asynchronous handler usually launches a process that can be lengthy and returns before
that process finishes

After writing and compili
ng the code to implement an HttpHandler you must register the
handler using your application's Web.config file.

.Net Interview Questions and Answers

What is .NET?

.NET is essentially a framework for software development. It is similar in nature to any
r software development framework (J2EE etc) in that it provides a set of runtime
containers/capabilities, and a rich set of pre
built functionality in the form of class
libraries and APIs

The .NET Framework is an environment for building, deploying, and r
unning Web Services
and other applications. It consists of three main parts: the Common Language Runtime,
the Framework classes, and ASP.NET.

How many languages .NET is supporting now?

When .NET was introduced it came with several languages. VB.NET, C#,
COBOL and Perl,
etc. The site DotNetLanguages.Net says 44 languages are supported.

How is .NET able to support multiple languages?

A language should comply with the Common Language Runtime standard to become a
.NET language. In .NET, code is compiled to
Microsoft Intermediate Language (MSIL for
short). This is called as Managed Code. This Managed code is run in .NET environment. So
after compilation to this IL the language is not a barrier. A code can call or use a function
written in another language.

ow ASP .NET different from ASP?

Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be
executed on the server.

What is smart navigation?

The cursor position is maintained when the page gets refreshed due to the server side
validation and the page gets refreshed.

What is view state?

The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page
itself automatically. How? The values are encrypted and saved in hidden controls. this is
done automatically by the ASP.NET. This can be switched off / on for a sing
le control

How do you validate the controls in an ASP .NET page?

Using special validation controls that are meant for this. We have Range Validator, Email

Can the validation be done in the server side? Or this can be done only in the
Client s

Client side is done by default. Server side validation is also possible. We can switch off the
client side and server side can be done.

How to manage pagination in a page?

Using pagination option in DataGrid control. We have to set the number of re
cords for a
page, then it takes care of pagination by itself.

What is ADO .NET and what is difference between ADO and ADO.NET?

ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in
database where in I can use relationships betwe
en the tables and select insert and
updates to the database. I can update the actual database as a batch.

Observations between VB.NET and VC#.NET?

Choosing a programming language depends on your language experience and the scope of
the application you ar
e building. While small applications are often created using only one
language, it is not uncommon to develop large applications using multiple languages.

For example, if you are extending an application with existing XML Web services, you
might use a sc
ripting language with little or no programming effort. For client
applications, you would probably choose the single language you are most comfortable
with for the entire application. For new enterprise applications, where large teams of
create components and services for deployment across multiple remote sites,
the best choice might be to use several languages depending on developer skills and long
term maintenance expectations.

The .NET Platform programming languages

including Visual

Basic .NET, Visual C#, and
Visual C++ with managed extensions, and many other programming languages from
various vendors

use .NET Framework services and features through a common set of
unified classes. The .NET unified classes provide a consistent meth
od of accessing the
platform's functionality. If you learn to use the class library, you will find that all tasks
follow the same uniform architecture. You no longer need to learn and master different API
architectures to write your applications.

In most

situations, you can effectively use all of the Microsoft programming languages.
Nevertheless, each programming language has its relative strengths and you will want to
understand the features unique to each language. The following sections will help you
hoose the right programming language for your application.

Visual Basic .NET

Visual Basic .NET is the next generation of the Visual Basic language from Microsoft. With
Visual Basic you can build .NET applications, including Web services and ASP.NET Web
pplications, quickly and easily. Applications made with Visual Basic are built on the
services of the common language runtime and take advantage of the .NET Framework.

Visual Basic has many new and improved features such as inheritance, interfaces, and
verloading that make it a powerful object
oriented programming language. Other new
language features include free threading and structured exception handling. Visual Basic
fully integrates the .NET Framework and the common language runtime, which together
provide language interoperability, garbage collection, enhanced security, and improved
versioning support. A Visual Basic support single inheritance and creates Microsoft
intermediate language (MSIL) as input to native code compilers.

Visual Basic is com
paratively easy to learn and use, and Visual Basic has become the
programming language of choice for hundreds of thousands of developers over the past
decade. An understanding of Visual Basic can be leveraged in a variety of ways, such as
writing macros in

Visual Studio and providing programmability in applications such as
Microsoft Excel, Access, and Word.

Visual Basic provides prototypes of some common project types, including:

• Windows Application.

• Class Library.

• Windows Control Library.


Web Application.

• ASP.NET Web Service.

• Web Control Library.

• Console Application.

• Windows Service.

• Windows Service.

Visual C# .NET

Visual C# (pronounced C sharp) is designed to be a fast and easy way to create .NET
applications, including Web se
rvices and ASP.NET Web applications. Applications written
in Visual C# are built on the services of the common language runtime and take full
advantage of the .NET Framework.

C# is a simple, elegant, type
safe, object
oriented language recently developed

by Microsoft
for building a wide range of applications. Anyone familiar with C and similar languages
will find few problems in adapting to C#. C# is designed to bring rapid development to the
C++ programmer without sacrificing the power and control that a
re a hallmark of C and
C++. Because of this heritage, C# has a high degree of fidelity with C and C++, and
developers familiar with these languages can quickly become productive in C#. C#
provides intrinsic code trust mechanisms for a high level of securit
y, garbage collection,
and type safety. C# supports single inheritance and creates Microsoft intermediate
language (MSIL) as input to native code compilers.

C# is fully integrated with the .NET Framework and the common language runtime, which
together pr
ovide language interoperability, garbage collection, enhanced security, and
improved versioning support. C# simplifies and modernizes some of the more complex
aspects of C and C++, notably namespaces, classes, enumerations, overloading, and
structured exce
ption handling. C# also eliminates C and C++ features such as macros,
multiple inheritance, and virtual base classes. For current C++ developers, C# provides a
powerful, high
productivity language alternative.

Visual C# provides prototypes of some common

project types, including:

• Windows Application.

• Class Library.

• Windows Control Library.

• ASP.NET Web Application.

• ASP.NET Web Service.

• Web Control Library.

• Console Application.

• Windows Service.