What methods are fired during the page load?

colonteeSoftware and s/w Development

Nov 4, 2013 (3 years and 10 months ago)

103 views

1.

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


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

2.

What methods are fired during the page load?


Init()
-

when the page is instantiated

Load()
-

when the page is
loaded into server memory

PreRender()
-

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

Unload()
-

when page finishes loading.

3.

When during the page processing cycle is ViewState available?


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

4.

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


System.Web.UI.Page

5.

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


CodeBehind is relevant to Visual Studio.NET only.

6.

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


CodeBehind is relevant to Visual Studio.NET only.

7.

What is the Global.asax used for?


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

8.

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.

9.

Whats an assembly?


Assemblies are the building blocks of the .NET framework;

10.

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
mputer.

11.

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


The Fill() method.

12.

Can you edit data in the Repeater control?


No, it just reads the information from its data source
.

13.

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


ItemTemplate.

14.

Name two properties common in every validation control?


ControlToValidate property and Text property.

15.

What base class do all Web Forms inherit from?


The Page class.

16.

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
round
-
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

17.

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
postabacks.

18.

What is the lifespan for items stored in ViewSt
ate?


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

19.

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
-
side
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.

20.

What are the different types of Session state management options available with
ASP.NET?


ASP.NET provides In
-
Process and Out
-
of
-
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
-
of
-
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
-
of
-
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
Cycle:


1)Page_PreInit

2)Page_Init

3)Page_InitComplete

4)Page_PreLoad

5)Page_Load

6)Control Events

7)Page_LoadComplete

8)Page_PreRender

9)SaveViewState

10)Page_Render

11)Page_Unload


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
er

so that


web server

can recognize you have already previously visited or not.


There are two types of

state management

techniques:

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
usly.


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
na
me.

Ex:


if(!IsPostBack)


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


you
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?

Application

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


Application

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

application.

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


Application

Object will be disposed once

application

will stop.

Cac
he Object can be disposed using Time based cache dependency.


Only one user can access

Application

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


6. what is boxing and unboxing?

Boxing

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

Unboxing

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



7. What are the uses of Reflection??

Reflection

is a concept using which we can



1) Load assemblies dynamically

2) Invoke

met
hods

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

events

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

events

to specify
event handlers like Page_Load or P
age_Init.


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

Below are the

events

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

explorer

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.?

Session

Management

can be achieved in two ways


1)InProc

2)OutProc


OutProc
is again two types

1)State Server

2)SQL Server


InProc

Adv.:

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

2) No need to serialize the data

DisAdv.:

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

Adv.:

1) Faster then

SQL Server

session

management


2) Safer then InProc. As IIS restart


won't effect the session data

DisAdv.:

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

Adv.:

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

DisAdv.:

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
Localization.

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?

Caching

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
application.


Caching

is of 3 types:

Output

Caching

-

Caches the whole page.

Fragment

Caching

-

Caches a part of the page

D
ata

Caching

-

Caches the data


17. What is meant by 3
-
tier architecture.

We generally split our

application

into 3
-
Layers

1)
Presentation

Layer

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

2)
Business

Layer

(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.

3)
Data Access

Layer

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

Block).

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
release
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?

machine.config

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

application

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

it is applicable to only one

application

i.e
each asp.net webapplication

will contain atleast on web.config

file.

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

using Exception Management application block

or

Page_error

Application_error objects

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

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

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 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?.

private

are

stored

in application / bin directory and public are

stored

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
above).

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.

Ho
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

25
. 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

Ex

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
othe
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.

H
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
Validator.

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


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
-
memory
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
-
server
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
developers
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
c
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
a
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
o
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.

• ASP.NET

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.