Vous êtes sur la page 1sur 17

LATEST DOT NET INTERVIEW QUESTIONS

What are Design Patterns?


A Design Pattern essentially consists of a problem in a software design and a solution to the same. In
Design Patterns each pattern is described with its name, the motivation behind the pattern and its
applicability.
According to MSDN, A design pattern is a description of a set of interacting classes that provide a
framewor! for a solution to a generali"ed problem in a specific conte#t or environment. In other words, a
pattern suggests a solution to a particular problem or issue in ob$ect%oriented software development.
Benefits of Design Patterns
&he following are some of the ma$or advantages of using Design Patterns in software development.
' (le#ibility ' Adaptability to change ' )eusability
When to use Design Patterns
Design Patterns are particularly useful in one of the following scenarios.
' *hen the software application would change in due course of time.
' *hen the application contains source code that involves ob$ect creation and event notification.
When not to use Design Patterns
. Do not use design patterns in any of the following situations.
' *hen the software being designed would not change with time.
' *hen the re+uirements of the source code of the application are uni+ue.
If any of the above applies in the current software design, there is no need to apply design patterns in the
current design and increase unnecessary comple#ity in the design.
The Gang of Four (GOF) Patterns
&he invention of the design patterns that we commonly use today can be attributed to the following four
persons, -rich .amma, )ichard /elm, )alph 0ohnson and 0ohn 1lissides. &hese men invented 23 patterns in
all that are commonly !nown as the .ang of (our patterns or the .4( patterns.
' 5reational ' Structural ' 6ehavioral
-ach of these groups in turn contains related sub patterns.
Creational Patterns
&he 5reational Patterns deals with the best possible way of creating an ob$ect or an instance of a class.
&hey simplify ob$ect creation and provide a fle#ible approach towards ob$ect creation. &he following are the
sub%patterns that fall under this group.
' Abstract (actory ' (actory ' 6uilder ' Prototype ' Singleton
6oth the Abstract (actory and the (actory pattern have the same intent.
&he Singleton Pattern indicates that there can be only one instance of a class throughout the Application7s
life cycle. A singleton class is one that can be instantiated only once in the application domain and provides
a global point of access to it.
Structural Patterns
Structural Patterns provides the fle#ibility to specify how ob$ects and classes can interoperate. &he following
are the sub patterns that comprise the Structural Patterns group.
' Adapter ' (a8ade ' 6ridge ' 5omposite
' Decorator ' (lyweight ' Pro#y ' Adapter
' 6ridge ' 5omposite ' Decorator ' (lyweight
' Pro#y
Behavioral Patterns
6ehavioral patterns help you define a structure for inter%ob$ect communication between ob$ects in your
system. &his design pattern is typically used to monitor the messages that are transmitted when the ob$ects
communicate in a system. &he following are the sub patterns under 6ehavioral Patterns.
' 5hain of )esponsibility ' 5ommand ' Interpreter ' Iterator
' Mediator ' Memento ' 4bserver ' State
' Strategy ' &emplate Method ' 1isitor
ASP.N-& M15 is a framewor! that allows developers to apply the M15 pattern in the development of an
ASP.N-& application, thus allowing a better separation of concerns, which results in better reusability and
easier testing.
M15 consists of three !inds of ob$ects
&he Model is an application ob$ect.
&he View is the screen presentation.
&he controller defines the way the user interface reacts to user inputs
&he re+uest comes from the client and hits the 5ontroller.
&he 5ontroller calls the Model in order to perform some business operations.
&he Model returns the results of the operations bac! to the 5ontroller.
&he 5ontroller decides which 1iew needs to be rendered and sends it the data that must be
rendered.
(inally the 1iew renders the output and sends the response bac! to the client.
What is Cryptography?
5ryptography is used to protect data and has many valuable uses. It can protect data from being viewed,
modified, or to ensure the integrity from the originator. 5ryptography can be used as a mechanism to
provide secure communication over an unsecured networ!, such as the Internet, by encrypting data, sending
it across the networ! in the encrypted state, and then the decrypting the data on the receiving end.
-ncryption can also be used as an additional security mechanism to further protect data such as passwords
stored in a database to prevent them from being human readable or understandable.
ncryption Co!ponents
-ncryption involves the use of a cryptography algorithm combined with a !ey to encrypt and decrypt the
data. &he goal of every encryption algorithm is to ma!e it as difficult as possible to decrypt the data without
the proper !ey. Data is translated from its originating form into something that appears meaningless unless
the proper algorithm and !ey are used to decrypt the data.
&he Microsoft .N-& (ramewor! classes 9System.Security.5ryptography: will manage the details of
cryptography for you. &he classes are implemented with the same interface; so wor!ing with the classes is
the same across the cryptography namespace.
Pu"lic#$ey ncryption
Public%!ey encryption, also !nown as asymmetric encryption, uses a public and private !ey pair to encrypt
and decrypt data. &he public !ey is made available to anyone and is used to encrypt data to be sent to the
owner of the private !ey. &he private !ey, as the name implies, is !ept private. &he private !ey is used to
decrypt the data and will only wor! if the correct public !ey was used when encrypting the data. &he private
!ey is the only !ey that will allow data encrypted with the public !ey to be decrypted. &he !eys can be
stored for use multiple times, or generated for a one%time use.
Asymmetric encryption algorithms are usually efficient for encrypting small amounts of data only. &he
following public%!ey algorithms are available for use in the .N-& (ramewor!.
Digital Signature Algorithm (DSA)
RSA
Private#$ey ncryption
Private%!ey -ncryption, also !nown as symmetric encryption, uses a single !ey to encrypt and decrypt
information. &he !ey must be !ept secret from those not authori"ed to decrypt the data lest the data be
compromised. Private%!ey algorithms are relatively fast and can be used to encrypt and decrypt large
streams of data. Private%!ey algorithms are !nown as bloc! ciphers because they encrypt data one bloc! at a
time. A bloc! cipher will encrypt the same input bloc! into the same output bloc! based on the algorithm and
!ey. If the anything were !nown about the structure of the data, patterns could be detected and the !ey
could possibly be reverse engineered. &o combat this, the classes in the .N-& (ramewor! use a process
!nown as chaining where information from the previous bloc! is used in encrypting the current bloc!. &his
helps prevent the !ey from being discovered. It re+uires an initiali"ation vector 9I1: be given to encrypt the
first bloc! of data.
&he following private%!ey algorithms are available in the .N-& (ramewor!. -ach description contains some
basic information about each algorithm, including the strengths and wea!nesses.
Data Encryption Standard (DES) algorithm encrypts and decrypts data in <=%bit bloc!s, using a <=%bit !ey.
-ven though the !ey is <=%bit, the effective !ey strength is only ><%bits. &here are hardware devices
advanced enough that they can search all possible D-S !eys in a reasonable amount of time. &his ma!es the
D-S algorithm brea!able, and the algorithm is considered somewhat obsolete.
)52 is a variable !ey%si"e bloc! cipher. &he !ey si"e can vary from ?%bit up to <=%bits for the !ey. It was
specifically designed as a more secure replacement to D-S. &he processing speed is two to three times
faster than D-S. /owever, the )525ryptoServiceProvider available in the .N-& (ramewor! is limited to ?
characters, or a <=%bit !ey. &he ?%character limitation ma!es it susceptible to the same brute force attac! as
D-S.
TripleDES algorithm uses three successive iterations of the D-S algorithm. &he algorithm uses either two or
three !eys. 0ust as the D-S algorithm, the !ey si"e is <=%bit per !ey with an effective !ey strength of ><%bit
per !ey. &he &ripleD-S algorithm was designed to fi# the shortcomings of the D-S algorithm, but the three
iterations result in a processing speed three times slower than D-S alone.
Rijndael algorithm, one of the Advanced -ncryption Standard 9A-S: algorithms, was designed as a
replacement for the D-S algorithms. &he !ey strength is stronger than D-S, and was designed to out
perform D-S. &he !ey can vary in length from @2?, @A2, to 2>< bits in length. &his is the algorithm I
personally trust the most and that IBll use for the e#amples contained in the column.
%ashing &lgorith!s
No, IBm not tal!ing about some type of drug related activity or an e#tra special recipe for brownies. /ashing
refers to mapping data of any length into a fi#ed%length byte se+uence. )egardless of if the input is the
contents of the library of 5ongress or the typing test &he +uic! brown fo# $umps over the la"y dog it will
result in an output of the same si"e. /ashing also produces uni+ue results. 0ust as no two snowfla!es are
identical, no two combinations of input will produce the same hash output. -ven if the input varies by a
single character it will produce different output. &he .N-& (ramewor! provides support for the following hash
algorithms of which IBll leave it up to you to discover which one is right for you based on the si"e of the data
you re+uire.
/MA5S/A@ MA5&ripleD-S MD>5ryptoServiceProvider S/A@Managed
S/A2><Managed S/A3?=Managed S/A>@2Managed
%o' to Generate a $ey an( )* for Private#+ey ncryption
-ach algorithm has specific !ey si"es that it e#pects for use. -ach !ey must fit a predetermined si"e typically
ranging from @ character 9?%bit: up to 32 characters 92><%bit:. Some of the algorithms support varying !ey
si"es, but they must be within the valid ranges of !ey si"e for the particular algorithm. (or our purposes,
weBll use )i$ndael, which supports @2?, @A2, and 2>< bit !eys. &he way to generate a @2?%bit !ey for use is
through one of the hashing algorithms. A phrase, or secret of any length can be hashed to generate a !ey
of the re+uired si"e for encrypting data. &he following code outlines a class containing a method that ta!es
an input phrase and generates a !ey and I1 for use.
,sing ncryption to Protect Sensitive Data Store( in a Data"ase
&his brings us to a possible and often overloo!ed use for encryption, which is encrypting data such as
passwords that are stored in a database. &here are several benefits to storing sensitive data such as
passwords in encrypted format.
It !eeps sensitive application data such as passwords secret from those authori"ed to view data that ideally
should not be able to see application specific data such as passwords.
It !eeps passwords protected from unauthori"ed access. If the database is somehow compromised, the
intruder must now the correct algorithm and !ey to decrypt the sensitive data.
Passing direct input to a +uery is dangerous because you never !now what the input may contain. Suppose a
stored procedure including something li!e */-)- vcCDogin E FDogin and Password E FPassword is used
for authentication. A user name of BmB or @E@ with the same for the password could evaluate to a true
statement and result in incorrectly allowing access. If the user id and or password were stored encrypted
then the data would not evaluate to a valid SGD statement because an encrypted form of the statement
would be used in the evaluation.
-- .e' Features of *isual Stu(io -//0 for 1.T Professionals
1 !"#$ Support
DING essentially is the composition of many standard +uery operators that allow you to wor! with data in a
more intuitive way regardless.
&he benefits of using DING are significant H 5ompile time chec!ing 5I language +ueries, and the ability to
debug step by step through +ueries.
% E&pression 'lend Support
-#pression blend is JAMD generator tool for silverlight applications. Kou can install -#pression blend as an
embedded plug%in to 1isual Studio 2LL?. 6y this you can get e#tensive web designer and 0avaScript tool.
( )indows *resentation +oundation
*P( provides you an e#tensive graphic functionality you never seen these before. 1isual Studio 2LL?
contains plenty of *P( *indows Presentation (oundation Dibrary templates. 6y this a visual developer who is
new to .N-&, 5I and 16.N-& can easily develop the 2D and 3D graphic applications.
1isual Studio 2LL? provides free game development library !its for games developers. currently this game
development !its are available for 5MM and also 2DN3D Dar! Matter one image and sounds sets.
, VS %--. Multi/Targeting Support
-arlier you were not able to wor!ing with .N-& @.@ applications directly in visual studio 2LL>. Now in 1isual
studio 2LL? you are able to create, run, debug the .N-& 2.L, .N-& 3.L and .N-& 3.> applications. Kou can
also deploy .N-& 2.L applications in the machines which contains only .N-& 2.L not .N-& 3.#.
0 A1A2 support 3or AS*#ET
Previously developer has to install A0AJ control library separately that does not come from 1S, but now if
you install 1isual Studio 2LL?, you can built%in A0AJ control library. &his A$a# Dibrary contains plenty of rich
A0AJ controls li!e Menu, &ree1iew, webparts and also these components support 0S4N and 1S 2LL? contains
in built ASP.N-& A0AJ 5ontrol -#tenders.
4 1a5aScript De6ugging Support
Since starting of web development all the developers got frustration with solving $avascript errors.
Debugging the error in $avascript is very difficult. Now 1isual Studio 2LL? ma!es it is simpler with $avascript
debugging. Kou can set brea! points and run the $avaScript step by step and you can watch the local
variables when you were debugging the $avascript and solution e#plorer provides $avascript document
navigation support.
7 #ested Master *age Support
Already 1isual Studio 2LL> supports nested master pages concept with .N-& 2.L, but the problem with this
1isual Studio 2LL> that pages based on nested masters canBt be edited using *KSI*K. web designer. 6ut
now in 1S 2LL? you can even edit the nested master pages.
. !"#$ "ntellisense and 1a5ascript "ntellisense support 3or sil5erlight applications
Most happy part for .N-& developers is 1isual Studio 2LL? contains intellisense support for $avascript.
0avascript Intellisense ma!es developers life easy when writing client side validation, A0AJ applications and
also when writing Silverlight applications
Intellisense Support, *hen we are writing the DING Guery 1S provides DING +uery synta# as tool tips.
8 9rgani:e "mports or ;sings
*e have 4rgani"e Imports feature already in -clipse. SInce many days I have been waiting for this feature
even in 1S. Now 1S contains 4rgani"e Imports feature which removes unnecessary namespaces which you
have imported. Kou can select all the namespaces and right clic! on it, then you can get conte#t menu with
4rgani"e imports options li!e )emove Onused Osings, Sort Osings, )emove and Sort. )efactoring
support for new .N-& 3.# features li!e Anonymous types, -#tension Methods, Dambda -#pressions.
1- "ntellisense +iltering
-arlier in 1S 2LL> when we were typing with intellisense bo# all the items were being displayed. (or e#ample
If we type the letter BPB then intellisense ta!es you to the items starts with BPB but also all other items will be
presented in intellisense bo#. Now in 1S 2LL? if you press BPB only the items starts with BPB will be filtered
and displayed.
11 "ntellisense 'o& display position
-arlier in some cases when you were typing the an ob$ect name and pressing . 9period: then intellisense was
being displayed in the position of the ob$ect which you have typed. /ere the code which we type will go bac!
to the dropdown, in this case sometimes programmer may disturb to what he was typing. Now in 1S 2LL? If
you hold the 5trl !ey while the intellisense is dropping down then intellisense bo# will become semi%
transparent mode.
1% Visual Studio %--. Split View
1S 2L> has a feature show both design and source code in single window. but both the windows tiles
hori"ontally. In 1S 2LL? we can configure this split view feature to vertically, this allows developers to use
ma#imum screen on laptops and wide%screen monitors.
/ere one of the good feature is if you select any /&MD or ASP mar!up te#t in source window automatically
corresponding item will be selected in design window.
1( <TM! 1a5aScript warnings= not as errors>
1S 2LL> mi#es /&MD errors and 5I and 16.N-& errors and shows in one window. Now 1S 2LL? separates
this and shows $avascript and /&MD errors as warnings. 6ut this is configurable feature.
1, De6ugging #ET +ramewor? !i6rary Source @ode>
Now in 1S 2LL? you can debug the source code of .N-& (ramewor! Dibrary methods. Dets say If you want to
debug the Data6ind9: method of Data.rid control you can place a debugging point over there and continue
with debug the source code of Data6ind9: method.
10 "n 6uilt Sil5erlight !i6rary
-arlier we used to install silverlight SDP separately, Now in 1S 2LL? it is inbuilt, with this you can create,
debug and deploy the silverlight applications.
14 Visual Studio !"#$ Designer
Already you !now in 1S 2LL> we have inbuilt SGD Server ID- feature. by this you no need to use any other
tools li!e SGD Server Guery Analy"er and SGD Server -nterprise Manger. Kou have directly database e#plorer
by this you can create connections to your database and you can view the tables and stored procedures in
1S ID- itself. 6ut now in 1S 2LL? it has 1iew Designer window capability with DING%to%SGD.
17 "n6uilt @AA SDB
-arlier It was so difficult to download and configure the 5MM SDP Dibraries and tools for developing windows
based applications. Now it is inbuilt with 1S 2LL? and configurable
1. Multilingual ;ser "nter3ace Architecture / M;"
MOI is an architecture contains pac!ages from Microsoft *indows and Microsoft 4ffice libraries. &his
supports the user to change the te#t language display as he wish.
1isual Studio is now in -nglish, Spanish, (rench, .erman, Italian, 5hinese Simplified, 5hinese &raditional,
0apanese, and Porean. 4ver the ne#t couple of months. Microsoft is reengineering the MOI which supports
nine local languages then you can even view 1isual studio in other A local languages.
18 Microso3t *op3ly Support
Microsoft Popfly e#plorer is an add%on to 1S 2LL?, by this directly you can deploy or hosting the Silverlight
applications and Marshup ob$ects
Deploy!ent Options Supporte( "y 1.T
Kou can deploy an ASP.N-& *eb application using any one of the following three deployment options.
2@9*C Deployment
;sing the @opy *roject option in VS #ET
Deployment using VS#ET installer
2COP3 Deploy!ent
6efore loo!ing at how .N-& enables J54PK deployment, let us ta!e a moment to understand what J54PK
deployment is. Prior to .N-&, installing a component 9for e#ample, a 54M 5omponent: re+uired copying the
component to appropriate directories, ma!ing appropriate registry entries, and so on. 6ut now in .N-&, to
install the component all you need to do is copy the assembly into the bin directory of the client application
and the application can start using it right away because of the self%describing nature of the assembly. &his
is possible because compilers in the .N-& (ramewor! embed identifiers or meta%data into compiled modules
and the 5D) uses this information to load the appropriate version of the assemblies. &he identifiers contain
all the information re+uired to load and run modules, and also to locate all the other modules referenced by
the assembly. It is also refered to as "ero%impact install since the machine is not impacted by way of
configuring the registry entries and configuring the component. &his "ero%impact install also ma!es it
possible to uninstall a component without impacting the system in any manner. All that is re+uired to
complete uninstallation is the removal of specific files from the specific directory. (or performing this type of
deployment, all you need to do is to go to the 5ommand Prompt and copy over the re+uired files to a specific
directory on the server using the J54PK command.
As you can see, the J54PK command ta!es a number of arguments.
N - % &his option copies directories, subdirectories, and files of the source argument, including empty ones.
N P % &his option allows you to retain all the e#isting file and folder attributes. *hen you use J54PK to copy
files or a directory tree structure, J54PK strips off file attributes by default. (or e#ample, if a file had the
read%only attribute set, that attribute would be lost after the file is copied. &o retain the original attributes
with the copied files, you must use the N P parameter.
N ) % &his option overwrites files mar!ed as read only.
N 4 % &his option preserves all security%related permission A5Ds of the file and folders.
N / % &his option copies both hidden and system files.
N I % &his option tells J54PK to assume that the destination is a directory and create it if it does not already
e#ist.
4nce the folder is copied over to the target server, you then need to create a virtual directory on the target
server 9using Internet Information Manager MM5 snap%in: and map that virtual directory to the physical
directory that is created using the J54PK command. &hatBs all there is to deploying an ASP.N-& *eb
application on a remote server using J54PK Deployment.
,sing the Copy Pro4ect Option in *S 1.T
&he 5opy Pro$ect option in 1S .N-& ma!es it very easy to deploy ASP.N-& *eb applications onto the target
servers. Osing this option, you can copy the *eb pro$ect to the same server or to a different server.
If you are using 1S .N-& to develop *eb applicatons, the first thing that you need to do before pac!aging an
ASP.N-& *eb applications is to change the Active Solution 5onfiguration from Debug to )elease as shown
below. &his allows the compiler not only to optimi"e the code but also remove the debugging related symbols
from the code, ma!ing the code run much faster. &o bring up the 5onfiguration Manager, select your *eb
pro$ect from the Solution -#plorer and select Pro$ect%QProperties%Q5onfiguration Properties from the menu
and then clic! on the 5onfiguration Manager 5ommand button. In the Active Solution 5onfiguration combo
bo#, select the )elease option.
&o copy the *eb pro$ect onto the target server, select Pro$ect%Q5opy Pro$ect from the menu. Selecting that
option will result in the following dialog bo# being displayed.
&he 5opy Pro$ect dialog provides the following options.
Destination Pro$ect (older, Osing this option, you can specify the location to which you want to copy the
pro$ect. &he location can be the same server or a remote server.
*eb access method, &he *eb access method option determines the access method that is used to copy the
*eb pro$ect to the destination folder. &here are two types of *eb access methods.
(ile share, &his option indicates that you want to directly access your pro$ect files on the *eb server through
a file share. It does not re+uire (rontPage Server -#tensions on the server.
(rontPage, &his option specifies that you want to use the /&&P%based (rontPage Server -#tensions to
transfer your pro$ect files to the server. 6efore using this option, ma!e sure (rontPage Server -#tensions are
installed on the server. &his option will automatically create the re+uired virtual directory on the target
server.
5opy, &he 5opy option provides three types,
4nly files needed to run this application, this option copies built output files 9DDDs and references from the
bin folder: and any content files 9such as .asp#, .asm# files:. Most of the time, you should be able to deploy
the application using this default option.
All pro$ect files, this option copies built outputs 9DDDs and references from the bin folder: and all files that
are in the pro$ect. &his includes the pro$ect file and source files.
All (iles in the source pro$ect folder, choosing this option will result in all the pro$ect files and any other files
that are in the pro$ect folder 9or subfolder: being transferred to the destination folder.
&o copy the *eb pro$ect, select the appropriate options from the above 5opy Pro$ect dialog bo# and clic! 4P.
&his will result in the ASP.N-& *eb application being deployed on the target server.
Deploy!ent ,sing *S 1.T We" Setup Pro4ect
-ven though J54PK deployment and 5opy Pro$ect options are very simple and easy%to%use, they do not lend
themselves well to all of the deployment needs. (or e#ample, if your application re+uires more robust
application setup and deployment re+uirements, 1S .N-& installer can be the right choice. Although you can
distribute your *eb application as a collection of build outputs, installer classes, and database creation
scripts, it is often easier to deploy comple# solutions with *indows Installer files. 1S .N-& provides *eb
setup pro$ects that can be used to deploy *eb applications. &hese *eb setup pro$ects differ from standard
setup pro$ects in that they install *eb applications to a virtual root folder on a *eb server rather than in the
Program (iles folder, as is the case with the applications installed using standard setup pro$ects.
Since 1S .N-& installer is built on top of *indows Installer technology, it also ta!es advantages of *indows
Installer features. 6efore starting on a discussion of 1S .N-& *eb Setup Pro$ect, let us understand the
architecture of *indows Installer technology that provides the core foundation on top of which the 1S .N-&
installer is built.
Features Provi(e( "y *S 1.T We" Setup Pro4ect
&he deployment pro$ect in 1S .N-& builds on features of the *indows installer by allowing us to perform the
following operations.
)eading or writing of registry !eys
5reating directories in the *indows file system on the target servers
Provides a mechanism to register components
Provides a way to gather information from the users during installation
Allows you to set launch conditions, such as chec!ing the user name, computer name, current operating
system, software application installed, presence of .N-& 5D) and so on.
Also ma!es it possible to run a custom setup program or script after the installation is complete.
In the ne#t section, we will see how to deploy our Deployment-#ample*ebApp using the 1S .N-& *eb Setup
Pro$ect.
Creating a We" Setup Pro4ect ,sing *S 1.T )nstaller
*e will start by adding a new *eb Setup Pro$ect to our Deployment-#ample*ebApp ASP.N-& *eb
application solution by selecting (ile%QAdd Pro$ect%Q New Pro$ect from the menu. In the New Pro$ect dialog
bo#, select Setup and Deployment Pro$ects from the Pro$ect &ypes pane and then select *eb Setup Pro$ect in
the &emplates pane as shown in the following figure.
After creating the pro$ect, you then need to add the output of the primary assembly and the content files of
the ASP.N-& *eb application to the setup pro$ect. &o do this, right clic! on the
Deployment-#ample*ebAppSetup pro$ect in the solution e#plorer and select Add%QPro$ect 4utput from the
conte#t menu. In the Add Pro$ect 4utput .roup dialog bo#, select Deployment-#ample*ebApp from the
Pro$ect combo bo# and select Primary 4utput from the list.
After adding the pro$ect output, you then need to add the related 5ontent (iles 9such as .asp# files, Images,
and so on: to the pro$ect. &o do this, again bring up the Add Pro$ect 4utput dialog bo# and then select
5ontent (iles from the list this time. It is illustrated in the following screenshot.
After adding the Primary output and the 5ontent (iles to the *eb Setup pro$ect, the solution e#plorer loo!s
as follows,
5onfiguring Properties through the Properties *indow
&here are a number of properties that you can set through the properties window of the *eb Setup pro$ect.
&hese properties determine the runtime display and behavior of the *indows installer file. &o accomplish
this, right clic! on the Deployment-#ample*ebAppSetup pro$ect from the solution e#plorer and select
Properties from the conte#t menu to bring up its properties window. &he dialog bo# shown below appears in
the screen.
As can be seen from the above screenshot, the properties window provides properties such as Author,
Description, Manufacturer, Support Phone and so on that can be very useful to the users 9who are installing
your application: of your application to get more details about your application.
)nstalling the &SP1.T We" &pplication
4nce you have created the *indows installer file 9.msi file:, then installing the ASP.N-& application in the
target servers is very straightforward. All you need to do is to double%clic! on the .msi file from the *indows
e#plorer. &his will initiate the setup wi"ard, which will wal! you through the installation steps. &he following
screenshot shows the first dialog bo# displayed during the installation.
5lic!ing on Ne#t in the above dialog bo# results in the following dialog bo#, where you can specify the virtual
directory that will be used to host this *eb application. &his is one of the handy features wherein the
creation of virtual directory is completely automated obviating the need for manual intervention. In part two
of this article, we will see how to set specific properties 9such as Directory Security, Default Document and
so on: on the virtual directory as part of the installation process.
In the above dialog bo#, you can also clic! on the Dis! 5ost... command button to get an idea of the space
re+uired for installing this *eb application. 5lic!ing on Ne#t in the above dialog bo# results in the following
dialog bo# where you are as!ed to confirm the installation.
*hen you clic! on Ne#t in the above dialog bo#, the installation will begin and the application will be
installed. If the application is successfully installed, you will see the following dialog bo#.
After installing the application, you can see the installed ASP.N-& application through the AddN)emove
Programs option 9that can be accessed through Start%QSettings%Q5ontrol Panel: in your computer. (rom
here, you can run the setup program to uninstall the application any time you want to.
Caching
&he ability to store data in the main memory and then allow for retrieval of the same as and when they are
re+uested.
5aching is a techni+ue of persisting the data in memory for immediate access to re+uesting program calls.
ASP.N-& supports three types of caching for *eb%based applications,
@. Page Devel 5aching 9called 4utput 5aching:
2. Page (ragment 5aching 9often called Partial%Page 4utput 5aching:
3. Programmatic or Data 5aching
Output Caching
4utput caching caches the output of a page 9or portions of it: so that a pageBs content need not be
generated every time it is loaded.
In a typical ASP.N-& page, every time the user views the page, the *eb server will have to dynamically
generate the content of the page and perform the relevant database +ueries 9which are a very e#pensive
tas! to do:.
5onsidering the fact that the page does not change for a certain period of time, it is always a good idea to
cache whatever is non%static so that the page can be loaded +uic!ly.
"n *age 9utput @aching, the entire page is cached in memory so all the subse+uent re+uests for the same
page are addressed from the cache itself.
"n *age +ragment @aching, a specific a portion of the page is cached and not the entire page. Page 4utput or
(ragment 5aching can be enabled or disabled at the Page, Application or even the Machine levels.

Data @aching allows us to cache fre+uently used data and then retrieve the same data from the cache as
and when it is needed. *e can also set dependencies so that the data in the cache gets refreshed whenever
there is a change in the e#ternal data store. &he e#ternal data store can be a file or even a database.
Accordingly, there are two types to dependencies, namely, file based and S+l Server based. &here are also
differing cache e#piration policies
Synta#, RSF 4utput5ache DurationE<L 1ary6yParamEnone SQ
&he above synta# specifies that the page be cached for duration of <L seconds and the value none for
1ary6yParamT attribute ma!es sure that there is a single cached page available for this duration specified.
T 1ary6yParam can ta!e various !ey parameter names in +uery string. Also there are other attributes li!e
1ary6y/eader, 1ary6y5ustom etc.
&he following is the complete synta# of page output caching directive in ASP.N-&.
RSF 4utput5ache DurationEno of seconds
DocationEAny U 5lient U Downstream U Server U None
1ary6y5ontrolEcontrol
1ary6y5ustomEbrowser Ucustomstring
1ary6y/eaderEheaders
1ary6yParamEparameter SQ
To store the output cache for a specifie( (uration
Declarative &pproach5
RSF 4utput5ache DurationE<L 1ary6yParamENone SQ
Progra!!atic &pproach5
)esponse.5ache.Set-#pires9Date&ime.Now.AddSeconds9<L::;
)esponse.5ache.Set5acheability9/ttp5acheability.Public:;

6 To store the output cache on the "ro'ser client 'here the re7uest originate(
Declarative &pproach5
RSF 4utput5ache DurationE<L DocationE5lient 1ary6yParamENone SQ
Progra!!atic &pproach5
)esponse.5ache.Set-#pires9Date&ime.Now.AddSeconds9<L::;
)esponse.5ache.Set5acheability9/ttp5acheability.Private:;

6 To store the output cache on any %TTP 818 cache#capa"le (evices inclu(ing the pro9y servers
an( the client that !a(e re7uest
Declarative &pproach5
RSF 4utput5ache DurationE<L DocationEDownstream 1ary6yParamENone SQ
Progra!!atic &pproach5
)esponse.5ache.Set-#pires9Date&ime.Now.AddSeconds9<L::;
)esponse.5ache.Set5acheability9/ttp5acheability.Public:;
)esponse.5ache.SetNoServer5aching9:;

6 To store the output cache on the We" server
Declarative &pproach5
RSF 4utput5ache DurationE<L DocationEServer 1ary6yParamENone SQ
Progra!!atic &pproach5
&imeSpan freshness E new &imeSpan9L,L,L,<L:;
Date&ime now E Date&ime.Now;
)esponse.5ache.Set-#pires9now.Add9freshness::;
)esponse.5ache.SetMa#Age9freshness:;
)esponse.5ache.Set5acheability9/ttp5acheability.Server:;
)esponse.5ache.Set1alidOntil-#pires9true:;

6 To cache the output for each %TTP re7uest that arrives 'ith a (ifferent City5
Declarative &pproach5
RSF 4utput5ache durationE<L varybyparamE5ity SQ
Progra!!atic &pproach5
)esponse.5ache.Set-#pires9Date&ime.Now.AddSeconds9<L::;
)esponse.5ache.Set5acheability9/ttp5acheability.Public:;
)esponse.5ache.1ary6yParamsV5ityW E true;
(or the 1ary6y5ustom attribute, the 1ary6y/eader attribute, and the 1ary6yParam attribute in the F
4utput5ache directive, the /ttp5achePolicy class provides the 1ary6y/eaders property and the
1ary6yParams
property, and the Set1ary6y5ustom method.
81 Page Output Caching
"n *age 9utput @aching, the entire page is cached in memory so all the subse+uent re+uests for the same
page are addressed from the cache itself.
Partial#Page Output Caching: Page Frag!ent Caching
"n *age +ragment @aching, a specific a portion of the page is cached and not the entire page. Page 4utput or
(ragment 5aching can be enabled or disabled at the Page, Application or even the Machine levels.
More often than not, it is impractical to cache entire pages. (or e#ample, you may have some content on
your page that is fairly static, such as a listing of current inventory, but you may have other information,
such as the userBs shopping cart, or the current stoc! price of the company, that you wish to not be cached
at all. Since 4utput 5aching caches the /&MD of the entire ASP.N-& *eb page, clearly 4utput 5aching cannot
be used for these scenarios, enter Partial%Page 4utput 5aching.
Partial%Page 4utput 5aching, or page fragment caching, allows specific regions of pages to be cached.
fragment caching comes from the attribute 1ary6y5ontrol. Osing this attribute one can cache a user
control based on the properties e#posed.
Synta#, RSF 4utput5ache DurationE<L 1ary6y5ontrolEDepartmentId SQ
&he above synta# when declared within an T.asc# file ensures that the control is cached for <L seconds and
the number of representations of cached control is dependant on the property DepartmentId declared in
the control.
Data Caching
Programmatic or data caching ta!es advantage of the .N-& )untime cache engine to store any data or ob$ect
between responses. &hat is, you can store ob$ects into a cache, similar to the storing of ob$ects in
Application scope in classic ASP.
)eali"e that this data cache is !ept in memory and lives as long as the host application does. In other
words, when the ASP.N-& application using data caching is restarted, the cache is destroyed and recreated.
Data 5aching is almost as easy to use as 4utput 5aching or (ragment caching, you simply interact with it as
you would any simple dictionary ob$ect.
Note that the Insert method allows you to simply add items to the cache using a !ey and value notation as
well. (or e#ample to simply add an instance of the ob$ect bar to the cache named foo, use synta# li!e this,
5ache.Insert9foo, bar:; NN 5I
5ache.Insert9foo, bar: B 16.N-&
Guestion % Define 5aching in ASP.N-&.
Answer % 5aching techni+ue allows to storeNcache page output or application data on the client. &he cached
information is used to serve subse+uent re+uests that avoid the overhead of recreating the same
information. &his enhances performance when same information is re+uested many times by the user.
Guestion % Advantages of 5aching
Answer % It increases performance of the application by serving user with cached output.
It decreases server round trips for fetching data from database by persisting data in the memory.
It greatly reduces overhead from server resources.
Guestion % *hat are the types of 5aching in ASP.N-&X
Answer % 5aching in ASP.N-& can be of the following types
Page 4utput 5aching
Page (ragment 5aching
Data 5aching
Guestion % -#plain in brief each !ind of caching in ASP.N-&.
Answer % Page 4utput 5aching
&his type of caching is implemented by placing 4utput5ache directive at the top of the .asp# page at design
time.
(or e#ample,
RSF4utput5ache DurationE 3L 1ary6yParamE DepartmentIdSQ
&he duration parameter specifies for how long the page would be in cache and the 1ary6yParam parameter
is used to cache different version of the page.
&he 1ary6yParam parameter is useful when we re+uire caching a page based on certain criteria.
Page (ragment 5aching
&his techni+ue is used to store part of a *eb form response in memory by caching a user control.
Data 5aching
Data 5aching is implemented by using 5ache ob$ect to store and +uic! retrieval of application data.
5ache ob$ect is $ust li!e application ob$ect which can be access anywhere in the application.
&he lifetime of the cache is e+uivalent to the lifetime of the application.
;uestion5#What (o you !ean "y Share Point Portal ?
&ns'er5 /ere I have ta!en information regarding Share Point Portal Server 2LL3 provides mainly access to
the crucial business information and applications. *ith the help of Share Point Server we can server
information between Public (olders, Data 6ases, (ile Servers and the websites that are based on *indows
server 2LL3. &his Share Point Portal is integrated with MSAccess and *indows servers, So we can get a *ide
range of document management functionality. *e can also create a full featured portal with readymade
navigation and structure.
;uestion5#What is cross page posting in &SP1.T-1/ ?
&ns'er5 *hen we have to post data from one page to another in application we used server.transfer
method but in this the O)D remains the same but in cross page posting there is little different there is
normal post bac! is done but in target page we can access values of server control in the source page.&his is
+uite simple we have to only set the Post6ac!Orl property of 6utton,Din!6utton or imagebutton which
specifies the target page. In target page we can access the PreviousPage property. and we have to use the
FPreviousPage&ype directive. *e can access control of PreviousPage by using the findcontrol method. *hen
we set the Post6ac!O)D property ASP.N-& framewor! bind the /&MD and 0avascript function automatically.
;uestion5 %o' to start Outloo+<.otePa( file in &sP1.T 'ith co(e ?
&ns'er5 /ere is the synta# to open outloo! or notepad file in ASP.N-& 16.N-& Process.Start9Notepad.e#e:
Process.Start9msimn.e#e:; 5I.N-& System.Diagnostics.Process.Start9msimn.e#e:;
System.Diagnostics.Process.Start9Notepad.e#e:;
;uestion5 What is the purpose of ))S ?
&ns'er5 *e can call IIS9Internet Information Services: a powerful *eb server that helps us creating highly
reliable, scalable and manageable infrastructure for *eb application which runs on *indows Server 2LL3.
IIS helps development center and increase *eb site and application availability while lowering system
administration costs. It also runs on *indows N&N2LLL platforms and also for above versions. *ith IIS,
Microsoft includes a set of programs for building and administering *eb sites, a search engine, and support
for writing *eb%based applications that access database. IIS also called http server since it process the http
re+uest and gets http response.
;uestion5 What is !ain (ifference "et'een Gri(=ayout an( For!=ayout ?
&ns'er5 .ridDayout helps in providing absolute positioning of every control placed on the page. It is easier
to develop page with absolute positioning because control can be placed any where according to our
re+uirement. 6ut (ormDayout is little different only e#perience *eb Developer used this one reason is it is
helpful for wider range browser. If there is absolute positioning we can notice that there are number of DI1
tags. 6ut in (ormDayout whole wor! are done through the tables.
;uestion5 %o' *isual SourceSafe helps ,s ?
&ns'er5 4ne of the powerful tool provided by Microsoft to !eep up%to%date of files system its !eeps records
of file history once we add files to source safe it can be add to database and the changes ads by different
user to this files are maintained in database from that we can get the older version of files to. &his also helps
in sharing,merging of files.
;uestion5#Can you (efine 'hat is SharePoint an( so!e overvie' a"out this ?
&ns'er5 SharePoint helps wor!ers for creating powerful personali"ed interfaces only by dragging and drop
pre%defined *eb Part 5omponents. And these *eb Parts components also helps non programmers to get
information which care and customi"e the appearance of *eb pages. &o under stand it we ta!e an e#ample
one *eb Part might display a userBs information another might create a graph showing current employee
status and a third might show a list of -mployees Salary. &his is also possible that each functions has a lin!
to a video or audio presentation. So now Developers are unable to create these *eb Part components and
ma!e them available to SharePoint users.
;uestion5#What is (ifferent "et'een We",serControl an( in We"Custo!Control ?
&ns'er5 We" user controls 5# *eb Oser 5ontrol is -asier to create and another thing is that its support is
limited for users who use a visual design tool one good thing is that its contains static layout one more thing
a separate copy is re+uired for each application.
We" custo! controls5#*eb 5ustom 5ontrol is typical to create and good for dynamic layout and another
thing is it have full tool support for user and a single copy of control is re+uired because it is placed in .lobal
Assembly cache.
;uestion5#What is San("o9 in S;= server an( e9plain per!ission level in S7l Server ?
&ns'er5 Sandbo# is place where we run trused program or script which is created from the third party.
&here are three type of Sandbo# where user code run.
Safe &ccess San("o9,%/ere we can only create stored procedure,triggers,functions,datatypes etc.6ut we
doesnot have acess memory ,dis! etc.
9ternal &ccess San("o9,%*e cn access (ile systems outside the bo#. *e can not play with
threading,memory allocation etc.
,nsafe &ccess San("o9,%/ere we can write unreliable and unsafe code.
;uestion5#%o' !any types of coo+ies are there in 1.T ?
&ns'er5 &wo type of coo!eies.
a: single valued eg re+uest.coo!ies9YOserNameY:.valueEYdotnet+uestionY
b:Multivalued coo!ies. &hese are used in the way collections are used e#ample
re+uest.coo!ies9Y5oo!iNameY:9YOserNameY:EYdotnet+uestionMaheshY
re+uest.coo!ies9Y5oo!iNameY:9YOserIDY:EYinterviewZ
;uestion5 When 'e get rror >%TTP ?/- Pro9y rror> ?
&ns'er5 *e get this error when we e#ecute ASP.N-& *eb pages in 1isual *eb Developer *eb server,
because the O)D randomly select port number and pro#y servers did not recogni"e the O)D and return this
error. &o resolve this problem we have to change settings in Internet -#plorer to bypass the pro#y server for
local addresses, so that the re+uest is not sent to the pro#y.
;uestion5#What (o you !ean "y three#tier architecture?
&ns'er5 &he three%tier architecture was comes into e#istence to improve management of code and contents
and to improve the performance of the web based applications. &here are mainly three layers in three%tier
architecture. the are define as follows
9@:Presentation
92:6usiness Dogic
93:Database
9@:First layer Presentation contains mainly the interface code, and this is shown to user. &his code could
contain any technology that can be used on the client side li!e /&MD, 0avaScript or 16Script etc.
92:Secon( layer is 6usiness Dogic which contains all the code of the server%side .&his layer have code to
interact with database and to +uery, manipulate, pass data to user interface and handle any input from the
OI as well.
93:Thir( layer Data represents the data store li!e MS Access, SGD Server, an JMD file, an -#cel file or even
a te#t file containing data also some additional database are also added to that layers.
;uestion5 What is Finali@er in 1.T (efine Dispose an( Finali@e?
&ns'er5 *e can say that (inali"er are the methods thatBs helps in clean up the code that is e#ecuted before
ob$ect is garbage collected .&he process is called finali"ation . &here are two methods of finali"er Dispose and
(inali"e .&here is little diffrenet between two of this method .
*hen we call Dispose method is realse all the resources hold by an ob$ect as well as all the resorces hold by
the parent ob$ect.*hen we call Dispose method it clean managed as well as unmanaged resources.
(inali"e methd also cleans resources but finali"e call dispose clears only the unmanged resources because in
finali"ation the garbase collecter clears all the ob$ect hold by managed code so finali"ation fails to prevent
thos one of methd is used that is, .5.Suppress(inali"e.
;uestion5 What is late "in(ing ?
&ns'er5 *hen code interacts with an ob$ect dynamically at runtime .because our code literally doesnot care
what type of ob$ect it is interacting and with the methods thats are supported by ob$ect and with the
methods thats are supported by ob$ect .&he type of ob$ect is not !nown by the ID- or compiler ,no
Intellisense nor compile%time synta# chec!ing is possible but we get unprecedented fle#ibilty in e#change.if
we enable strict type chec!ing by using option strict on at the top of our code modules ,then ID- and
compiler will enforce early binding behaviour .6y default Date binding is done.
;uestion5#Does 1.T C=A an( S;= SA*A run in (ifferent process?
&ns'er5 Dot Net 5D) and all .net relates application and S+l Server run in same process or we can say that
that on the same address because there is no issue of speed because if these two process are run in
different process then there may be a speed issue created one process goes fast and other slow may create
the problem.
;uestion5 The )%ttp%an(ler an( )%ttp%an(lerFactory interfaces ?
&ns'er5 &he I/ttp/andler interface is implemented by all the handlers. &he interface consists of one
property called Is)eusable. &he Is)eusable property gets a value indicating whether another re+uest can use
the I/ttp/andler instance. &he method Process)e+uest9: allows you to process the current re+uest. &his is
the core place where all your code goes. &his method receives a parameter of type /ttp5onte#t using which
you can access the intrinsic ob$ects such as )e+uest and )esponse. &he I/ttp/andler(actory interface
consists of two methods % .et/andler and )elease/andler. &he .et/andler9: method instantiates the
re+uired /&&P handler based on some condition and returns it bac! to ASP.N-&. &he )elease/andler9:
method allows the factory to reuse an e#isting handler.
;uestion5 'hat is *ie'state?
&ns'er51iew state is used by the ASP.N-& page framewor! to automatically save the values of the page
and of each control $ust prior to rendering to the page. *hen the page is posted, one of the first tas!s
performed by page processing is to restore view state.
State management is the process by which you maintain state and page information over multiple re+uests
for the same or different pages.
Client#si(e options are5
T &he 1iewState property T Guery strings T /idden fields T 5oo!ies
Server#si(e options are5
T Application state T Session state T Data6ase
Ose the 1iew State property to save data in a hidden field on a page. 6ecause 1iewState stores data on the
page, it is limited to items that can be seriali"ed. If you want to store more comple# items in 1iew State, you
must convert the items to and from a string.
ASP.N-& provides the following ways to retain variables between re+uests,
Conte9t1%an(ler o"4ect Ose this ob$ect to retrieve public members of one *eb form7s class from a
subse+uently displayed *eb form.
;uery strings Ose these strings to pass information between re+uests and responses as part of the *eb
address. Guery strings are visible to the user, so they should not contain secure information such as
passwords.
Coo+ies Ose coo!ies to store small amounts of information on a client. 5lients might refuse coo!ies, so your
code has to anticipate that possibility.
*ie' state ASP.N-& stores items added to a page7s 1iewState property as hidden fields on the page.
Session state Ose Session state variables to store items that you want !eep local to the current session
9single user:.
&pplication state Ose Application state variables to store items that you want be available to all users of
the application.
Descri"e the security authentication flo' an( process in &SP1.T?
*hen a user re+uests a web page, there e#ists a process of security too, so that every anonymous user is
chec!ed for authentication before gaining access to the webpage. &he following points are followed in the
se+uence for authentication when a client attempts a page re+uest,
A .asp# web page residing on an IIS web server is re+uested by an end user
IIS chec!s for the userBs credentials
Authentication is done by IIS. If authenticated, a to!en is passed to the ASP.N-& wor!er process
along with the re+uest
6ased on the authentication to!en from IIS, and on the web.config settings for the re+uested
resource, ASP.N-& impersonates the end user to the re+uest thread. (or impersonation, the
web.config impersonate attributeBs value is chec!ed.
What is &uthentication? What are the (ifferent types of &uthentication?

In a client%server environment, there are plenty of cases where the server has to interact and identify the
client that sends a re+uest to the server. Authentication is the process of determining and confirming the
identity of the client.
If a client is not successfully identified, it is said to be anonymous.
*indows Authentication (orms Authentication Passport Authentication
-ssentially the *indows Authentication and (orms Authentication are the famous ones, as Passport
Authentication is related to a few websites 9li!e microsoft.com, hotmail.com, msn.com etc. only:.
*indows Authentication is implemented mostly in Intranet scenarios. *hen a browser 9client: sends a
)e+uest to a server where in windows authentication has been implemented, the initial re+uest is
anonymous in nature. &he server sends bac! a )esponse with a message in /&&P /eader. &his Prompts a
*indow to display a Modal Dialog 6o# on the browser, where the end user may enter the Oser name and
Password.
&he end user enters the credentials, which are then validated against the Oser Store on the *indows server.
Note that each user who access the *eb Application in a *indows Authentication environment needs to have
a *indows Account in the company networ!.
/ow to avoid or disable the modal dialog bo# in a *indows Authentication environmentX
6y enabling the *indows Integrated Authentication chec!bo# for the web application through settings in IIS.
(orms Authentication is used in Internet based scenarios, where its not practical to provide a *indows based
account to each and every user to the *eb Server. In a (orms Authentication environment, the user enters
credentials, usually a Oser Name and a corresponding Password, which is validated against a Oser
Information Store, ideally a database table.
(orms Authentication &ic!et is the coo!ie stored on the userBs computer, when a user is authenticated. &his
helps in automatically logging in a user when heNshe re%visits the website. *hen a (orms Authentication
tic!et is created, when a user re%visits a website, the (orms Authentication &ic!et information is sent to the
*eb Server along with the /&&P )e+uest.
Descri"e the Provi(er Bo(el in &SP1.T -1/?
&he Provider model in ASP.N-& 2.L is based on the Provider Design Pattern that was created in the year
2LL2 and later implemented in the .N-& (ramewor! 2.L.
&he Provider Model supports automatic creation of users and their respective roles by creating entries of
them directly in the SGD Server 9May even use MS Access and other custom data sources:. So actually, this
model also supports automatically creating the user tableBs schema.
&he Provider model has 2 security providers in it, Membership provider and )ole Provider. &he membership
provider saves inside it the user name 9id: and corresponding passwords, whereas the )ole provider stores
the )oles of the users.
(or SGD Server, the S+lMembershipProvider is used, while for MS Access, the AccessMembershipProvider is
used. &he Security settings may be set using the website adminstration tool. Automatically, the
AccessMembershipProvider creates a Microsoft Access database file named aspnetdb.mdb inside the
applicationBs AppCData folder. &his contains @L tables.
Descri"e the Personali@ation in &SP1.T -1/?
ASP.N-& 2.L Personali"ation % Personali"ation allows information about visitors to be persisted on a data
store so that the information can be useful to the visitor when they visit the site again. In ASP.N-& 2.L, this
is controlled by a Personali"ation API. 6efore the Personali"ation Model came into e#istence, the prior
versions of ASP.N-& used of the old Session ob$ect to ta!e care of re%visits. Now comes the Profile ob$ect.
In order to use a Profile ob$ect, some settings need to be done in web.config. &he e#ample below shall
e#plain how to use a profile ob$ect,
NNAdd this to System.*eb in web.config
RprofileQ
RpropertiesQ
Radd nameE(irstName typeESystem.StringNQ
RNpropertiesQ
RNprofileQ
BIn PageCDoad event, add the following...
If Profile.(irstName RQ &hen
Panel@.1isible E (alse
)esponse.*rite9*elcome 6ac! Dear ,, [ Profile.(irstName [ , [ Profile.DastName:
-lse
Panel@.1isible E &rue
-nd If
B/ere is the code how to save the profile properties in an event to save it
Profile.(irstName E t#t(irstName.&e#t
9plain a"out Generics?
.enerics are not a completely new construct; similar concepts e#ist with other languages. (or e#ample, 5MM
templates can be compared to generics. /owever, thereBs a big difference between 5MM templates and .N-&
generics. *ith 5MM templates the source code of the template is re+uired when a template is instantiated
with a specific type. 5ontrary to 5MM templates, generics are not only a construct of the 5I language;
generics are defined with the 5D). &his ma!es it possible to instantiate generics with a specific type in 1isual
6asic even though the generic class was defined with 5I.
Why 'e use Seriali@ation?
Seriali"ation of data using built%in .N-& support ma!es persistence easy and reusable.
Most uses of seriali"ation fall into two categories, persistence an( (ata interchange1 Persistence allows
us to store the information on some non%volatile mechanism for future use. &his includes multiple uses of
our application, archiving, and so on. Data interchange is a bit more versatile in its uses. If our application
ta!es the form of an N%tier solution, it will need to transfer information from client to server, li!ely using a
networ! protocol such as &5P. &o achieve this we would seriali"e the data structure into a series of bytes that
we can transfer over the networ!. Another use of seriali"ation for data interchange is the use of JMD
seriali"ation to allow our application to share data with another application altogether. As you can see,
seriali"ation is a part of many different solutions within our application.
What is Seriali@ation?
Seriali"ation is the process of converting an ob$ect, or group of ob$ects, into a form that can be persisted.
*hen u seriali"e an ob$ect, you also seriali"e the values of its properties.
%o' Do 3ou ,se Seriali@ation?
Seriali"ation is handled primarily by classes and interfaces in the Syste!1Aunti!e1Seriali@ation
namespace. &o seriali"e an ob$ect, you need to create two things,
A stream to contain the seriali"ed ob$ects.
A formatter to seriali"e the ob$ects into the stream.
The Aole of For!atters in 1.T Seriali@ation
A formatter is used to determine the seriali"ed format for ob$ects. All formatters e#pose the I(ormatter
interface, and two formatters are provided as part of the .N-& framewor!,
6inary(ormatter provides binary encoding for compact seriali"ation to storage, or for soc!et%based
networ! streams. &he 6inary(ormatter class is generally not appropriate when data must be passed
through a firewall.
Soap(ormatter provides formatting that can be used to enable ob$ects to be seriali"ed using the
S4AP protocol. &he Soap(ormatter class is primarily used for seriali"ation through firewalls or among
diverse systems. &he .N-& framewor! also includes the abstract (ormatter class that may be used as
a base class for custom formatters. &his class inherits from the I(ormatter interface, and all
I(ormatter properties and methods are !ept abstract, but you do get the benefit of a number of
helper methods that are provided for you.

Vous aimerez peut-être aussi