Sie sind auf Seite 1von 10

1. Which of the two is better:- Strong Typing or Weak Typing?

Ans. Both Strong Typing and Weak Typing are good. Both are used depending on the requirement. In
Strong Typing the data type of the variables is checked as soon as possible, i.e. ithout any delay.So
in this sort of case data types are checked during compliation. This type is used hen you have large
programs. !n the other hand in Weak Typing the data type is checked as late as possible,i.e it delays
the checkin of the data type. In this case data types are checked at run"time. It is beneficial for smaller
scripts.
2. What do you mean by ViewState and what is its role?
Ans. #ieState is a state hich represents the state of the page that must persist across postback.
$ole of #ieState%" In AS&.net , the state of the eb page is the property hicgh controls the list of
hierarchy. That's hy it is important.
3. ow does the !aise"ubble#$ent works?
Ans. $aiseBubble(vent implementation is done ith the help of control , hich cannot be overridden.
The event data is sent up the hierarchy to the control's parent by $aiseBubble(vent. In order to raise
a bubbled event , the control has to override the !nBubble(vent method.
4. State difference between %age.!egister&lientScript"lock and %age.!egisterStartupScript?
Ans. &age.$egister)lientScriptBlock%" It is meant for the functions hich must be available to the
page. *or this purpose they are alays kept at the start of the +T,- file or AS&.net file. These
methods places the Scripts directly after the opening of the tag in the page.
&age.$egisterStartupScript %" These are meant for the commands hich are required at the time of
page load, so as the page is available for the script. This script resides at the end of the +T,- file or
AS&.net file.They are placed at the end of the element.
5. 'iffrentiate between src and code behind?
Ans. src%" It is an attribute here e mention the name of the code"behind class to dynamically
compile and deploy as needed by .IT. )ode"behind%" It contains or represents the logic behind the
/ser Interface. It refers to the code that is contained in a seperate class file. It allos a clean
seperation of the +T,- user interface page from the asp.net coded page.
6. What is the role of the following in the page load process:- inetinfo.e(e) aspnet*isapi.dll
andaspnet*wp.e(e .
Ans. inetinfo.e0e is the,icrosoft IIS server running, handling AS&.1(T requests among other
things.When an AS&.1(T request is received 2usually a file ith .asp0 e0tension3,the ISA&I filter
aspnet4isapi.dll takes care of it by passing the request to the actual orker process aspnet4p.e0e.
+. Write the code to write cookie from a client,s computer.
Ans. The folloing code rite a cookie to the user client. The cookie is 5/ser5 stores
/sername,&assord and -ast#isit.Assuming that the user interface is already designed ith controls
to enter 5/sername5 and 5&assord5 and there is a button to rite the cookie. The button is named
5Write )ookie5.)ode for the rite cookie is as follos%"
protected void Write)ookieButton4)lick2ob6ect sender, (ventArgs e3
7
88 )reate an instance of +ttp)ookie class
+ttp)ookie /ser)ookie 9 ne +ttp)ookie25/ser53:
88 &opulate /sername, passord and -ast#isit fields
/ser)ookie;5username5< 9 /sernameTe0tBo0.Te0t:
/ser)ookie;5&assord5< 9 &assordTe0tBo0.Te0t:
/ser)ookie;5-ast#isit5< 9 =ateTime.1o.ToString23:
88 Set the cookie e0piration date /ser)ookie.(0pires 9 =ateTime.1o.Add=ays2>3: 88
Write the cookie to the client computer $esponse.)ookies.Add2/ser)ookie3: ?
8. What is the purpose of page class ?
Ans. Whenever an asp.net page is requested and directed toards the broser , AS&.net creates an
instance of the class that represents the requested page.The page class is defined in System.Web./I
namespace. The page class provides all the useful properties and methods that are required hile
coding of asp.net page.
9. What is meant by pre-compilation feature of asp.net ?
Ans: &re")ompilation optio allos to compile the ebsite before its is deployed or compile it after
being deployed but before the request of the user.
10. What do you mean by bubbling an e$ent?
Ans. AS&.net provides a technique knon as event bubbling hich allos a child control to propagate
events up iys hierarchy. It can also be said that hen a control changes its state by the change in
state of some other control. *or e0ample if a value is selected from a combo bo0 it can change the
value in the data grid also.
11.-s it possible to create a custom control in asp.net? -f yes) then how?
Ans. @es, creating a custom control is possible in AS&.net. )ustom controls are user defined controls
and are created by grouping e0isting controls from System.Web./I.Web)ontrols.Web)ontrol. The
folloing steps are to folloed in order to create a )ustom )ontrol%" A. @ou have to create a custom
control library. B. Then rite the appropriate code for it, such that hat ill that control do should be
ritten in the form of a code. >. After riting the code compile the control -ibrary. C. 1o copy the dll
of the control library to the pro6ect here it is to be used. D. 1o it can be declared on the eb page
using E$egister tag
12. Suppose a certain .S%./et function is e(ecuted on 0ouse1$er for a specific button) then
where would you add an e$ent handler?
Ans: The ,ouse!ver attribute is added to the button. The code is as follos%"
Buuton41ame.Attributes.Add25onmouseover5,5)lient)ode23:53:
13. .ssume a situation where one person is logged in and he lea$es the system without
logging off. /ow the second person comes and try to log in his account. /ow it is re2uired that
as soon the new person logs in the seesion of the first user automatically ge
Ans. The folloing to lines in the page load event of login page can help in solving this situation%"
formsauthentication.signout23 session.abandon23
13. 'iifrentiate between 40achine.config4 and 4Web.config4?
Ans. ,achine.)onfig%" This file applies settings to all the AS&.net applications. We.)onfig%" This files
helps in applying settings to all the eb appliactions.
15. 'efine assembly?
Ans. Assembly is the unit of deployment hich can be an (F( file or a .=-- file. It consist of one or
more files and represent a group of resources , type definitions and implementing files and refrence to
other assemblies2if any3.
16.'iffrentiate between 'ata7rid and 'ata8ist?
Ans. Both datagrid and datalist are used for displaying the data. But there are several differences
beteen the to controls. A. =atalist don't have paging option and on the other hand datagrid have the
paging option. B. =atalist is having a property knon as repeat hich help in designing the layouts for
the datalist but this property not incorporated in =atagrid. -ayout designing is not possible in =atagrid.
>.=atalist provides better performance as compared to datagrid. C. =atagrid ro displays one record
from the data source, hile datlist ro can display more than one records from the data source.
1+. What is the difference between Session..bandon9: and Session.&lear9:?
Ans. Session.Abandon23 method destroys all the ob6ects stored in a Session ob6ect and releases their
resources. So Session.Abandon23 destroys the current session and causes a ne session to be
created thus causing the Session4!n(nd and Session4!nStart events to fire.
Session.)lear23 6ust removes all values8content from the Session !b6ect. The session ith the same
key is still alive.
1;. ow can we !estart an .pplication %ool?
$estart Application &ool ith IIS ,anager%
A3 !pen IIS ,anager.
B3 (0pand the Server node.
>3 (0pand the Application &ools folder.
>3 $ight"click on the application pool that you ant to restart and then select Stop.
C3 $ight"click on the application pool again and then select Start.
$estart Application &ool ith cscript.e0e in )ommand &rompt%
A3 In the command prompt, type the folloing command%
cscript.e0e c%GindosGsystem>BGiisapp.vbs 8a 5=efaultApp&ool5
1<. . web page page1.asp( calls page=.asp( to perform some computation. %age=.asp( does
not ha$e a >-. What code statement should be used to in$oke page=.asp(?
Ans% Server.e0ecute2HpageB.asp0I3
=?. When does the %rerender e$ent occurs and what is its importance?
Ans. &rerender event happens 6ust before the page renders itself. ,ore elaborately, it is the last event
in the life cycle of asp.net i.e. before the page is displayed to the user. The importance or significance
of this event is that it is the last place to make changes after that the page ill be displayed to the
user.
=1. ow many type of authentication modes are there in .S%./et?
Ans% There are three modes of Authentication%"
1. Windows .uthentication:" AS&.1(T uses Windos authentication in con6unction ith IIS
authentication. IIS performs authentication in one of three ays% basic, digest, or Integrated
Windos Authentication. When IIS authentication is complete, AS&.1(T uses the
authenticated identity to authoriJe access.
2. @orms .uthentication:- The user provides data and submits the form. If the application
authenticates the request, the system issues a cookie that contains the key for reacquiring the
identity. *urther requests are issued ith the help of cookie .
3. %assport .uthentication:- This is a )entraliJed authentication service provided by
,icrosoft.This service offers a single logon and core profile services for member sites.
==. -s it possible to look at the -8 for an assembly?
Ans%@es, one can vie I- for an assembly. I- stands for Intermediate -anguage. It can be vieed ith
a tool provided by microsoft in the .net frameork called as Ildasm.
=A. Which class manages the $iew state of .S%./#T ser$er controls) including pages?
Ans% StateBag class. This class can not be inherited. Synat0%" &ublic 1otInheritable )lass StateBag 4
Implements IState,anager, I=ictionary, I)ollection, I(numerable
=3. &an we pre$ent a browser from caching an .S%B page?
Ans%@es , it can be prevented by using $esponse.)ache.Set1oStore23 method.
=5.What is the use of 4.uto%ost"ack4 property?
Ans% This property is used hen it is desired by the control to post back to the server before moving
on to the ne0t Speech )ontrol. By default this property is set to false. *or eg. Whenever there is a
change in the value of the check bo0, e need to send it immediately to the server side. So in this
case 5Auto&ostBack5 property is set to true.
=6. /ame the different isolation le$els in --S?
Ans% IIS has > isolation levels%"
A. -o level 2IIS process3%" In this level process and AS&.1et application runs in the same
process. So if any of them crashes the other is also effected ith the crash.
B. ,edium -evel 2&ooled3%" In medium level the IIS and Application runs in different process, i.e
there are to processes. !ne is having IIS and the other is having AS&.net applcation.
>. +igh -evel 2Isolated3%" At this level each process is run in individual process. This occupies
large memory but posses high reliability.
=+. /ame the methods which are there in the Thread class?
Ans% Abort23 ,Ket=ata23 ,KetInformation23 ,Interupt23 ,.oin23 ,$esume23,
Set=ata23, Sleep23 ,Start23, Suspend23
=;.-s there any difference between aCCb and a.#2uals9b:?
Ans% Both are used for comparisons but it depends hether they are being compared value based or
refrence based.
#alue Based%" *or the type 5995 and 5(quals5 orks e0actly the same such as ill compare the values
and ill return true if a nd b have equal values in them. (0ample%" int a 9 A: int b9 A: a 99 b LL True
a.(quals2b3 LL True
$efrence Based%" In this case 5995 compares the refrence and returns true if and only if both refrence
points are same. But 5(qual5 still compares the value at that refrence points.. So if values are same
the result ill be true else false. (0ample%" StringBuilder a 9 ne StringBuilder2H+elloI3: StringBuilder b
9 ne StringBuilder2H+elloI3: a 99 b LL *alse a.(quals2b3 LL True But no look at folloing issue%
String a 9 H+elloI: String b 9 H+elloI: In above case the results ill be, a 99 b LL True a.(quals2b3 LL
True
=<.What is the purpose of the 7lobal.asa( file?
Ans% It used to implement session level and applcation level events raised by AS&.net or by +TT&
modules. It is also knon as AS&.net application file and resides in the root directory of the AS&.1(T
application.
A?.-s there any limit of imposing cookies in a single application?
Ans% @es, only BM cookies can be used in a single eb application.
A1. What is the use of .pplication*Start method?
Ans. Application4Start is a special method of AS&.1et hich do not represent +TT&Application events.
Application4Start method is called hen the first resource such as a page is of an AS&.1et application
is called up.This method is used to perform startup task such as initialising the static values and
loading data into the cache. This method is caleed only once during the llfe cycle of the application.
A=. #(plain the $arious types of .S%./et &aching?
Ans% Basically, AS&.1et )aching is of to types%
A3 !utput )aching%
The rendered html page is stored into the cache before sending it to the client. 1o, if the same page
is requested by some other client the already rendered htm page is retrieved from the server memory
and sent to the client, hich saves the time requires rendering and processing the complete page.
B3 =ata )aching%
The important pieces of information, that are time consuming and frequently requested, are stored into
the cache. *or e0ample a data set retrieved from the database. It is very similar to application state
but it is more server friendly as the data gets removed once the cache is filled.
There are to more models hich are built on the above to types%
*ragment caching%
Instead of caching the complete page, some portion of the rendered html page is cached. (.g.% /ser
)ontrol used into the page is cached and so it doesnNt get loaded every time the page is rendered.
=ata Source )aching%
It is caching built into the data source controls 2eg. Fml=ataSource, sql=ataSource etc3. It is very
similar to data caching but here the caching is not handled e0plicitly but the data source control
manages it as per the settings made on the data controls.
AA. #(plain .S%./et &aching?
Ans% AS&.1et )aching is a mechanism to store the frequently used data into the server memory hich
can be retrieved very quickly. And so provides both scalability and performance. *or e0ample if user is
required to fetch the same data from database frequently then the resultant data can be stored into the
server memory and later retrieved in very less time 2better performance3. And the same time the
application can serve more page request in the same time 2scalability3.
But it also have some drabacks. Suppose the server memory is filled ith the data then the
remaining part of the data is stored into the disk hich slo don the complete system performance.
That's hy self limiting caching techniques are best: here once the server memory gets filled the
data has been selectively removed from the server memory to ensure that the application performance
is not degraded.
A3. What is the difference between trace and debug in .S%./#T?
Ans% =ebug and trace enables you to monitor the application for errors and e0ception ithout #S.1(T
I=(.
In =ebug mode compiler inserts some debugging code inside the e0ecutable. As the debugging code
is the part of the e0ecutable they run on the same thread here the code runs and they do not given
you the e0act efficiency of the code 2as they run on the same thread3. So for every full e0ecutable =--
you ill see a debug file also as shon in figure '=ebug ,ode'.
Trace orks in both debug as ell as release mode. The main advantage of using trace over debug is
to do performance analysis hich can not be done by debug. Trace runs on a different thread thus it
does not impact the main code thread.
A5. What is the use of .uto#$entWireup attribute in %age directi$e?
Ans% If the value of Auto(ventWireup attribute is set to false, then you need to hook up events to
events handlers manually. If it is set to true, then the AS&.1(T page frameork can automatically raise
events.
A6. What is the difference between authentication and authoriDation?
Ans% Authentication%
An authentication system is ho you identify yourself to the computer. The goal behind an
authentication system is to verify that the user is actually ho they say they are. There are many ays
of authenticating a user. -ike &assord based authentication, =evice based authentication, Biometric
Authentication, etc.
AuthoriJation%
!nce the system knos ho the user is through
authentication, authoriJation is ho the system decides hat the user can do. A good e0ample of this
is using group permissions or the difference beteen a normal user and the superuser on a uni0
system.
A+. Which obEect is used to share $ariables across all the users in an .S%./et web application?
Ans% Application !b6ect
A;. What is Web Ser$ice 'escription 8anguage 9WS'8:?
Ans% Web Service description language 2WS=-3 is basically an F,- document hich describes the
eb service. It gives details like service method names, their parameter data types, return values, etc.
A<. What are the $arious modes of .S%./et SessionState?
Ans% AS&.1(T supports three modes of session state%
In&roc%
In"&roc mode stores values in the memory of the AS&.1(T orker process. Thus, this mode offers the
fastest access to these values. +oever, hen the AS&.1(T orker process recycles, the state data
is lost.
StateServer%
Alternately, StateServer mode uses a stand"alone ,icrosoft Windos service to store session
variables. Because this service is independent of ,icrosoft Internet Information Server 2IIS3, it can run
on a separate server. @ou can use this mode for a load"balancing solution because multiple Web
servers can share session variables. Although session variables are not lost if you restart IIS.
SqlServer%
SqlServer mode is similar to out"of"process mode, e0cept that the session data is maintained in a SO-
Server. SqlServer mode also enables you to utiliJe a state store that is located out of the IIS process
and that can be located on the local computer or a remote server.
3?. What is a ViewState?
Ans%#ieState is the technique used by an AS&.1(T Web page to persist changes to the state of a
Web *orm across postbacks. #ieState allos the state of ob6ects 2serialiJable ob6ects3 to be stored
in a hidden field on the page. #ieState is transported to the client and back to the server, and is not
stored on the server or any other e0ternal source. #ieState is used to retain the state of server"side
ob6ects beteen post backs.
31.What happens in the 1n-nit e$ent of a web control?
Ans% (ach child control of the current eb control is initialiJed.
3=. -n which namespace the @orms.uthentication class is present?
Ans%System.Web.Security namespace
3A. %age 8ife &ycle :-
Ans% %re-nit%
You can:
Check for the IsPostBack property to determine whether this is the first time the page is
being processed.
Create or recreate dynamic controls.
Set master page dynamically.
Set the Theme property dynamically.
ead or set profile property !alues.
"f e#uest is postback:
$he !alues of the controls ha!e not yet been restored from !iew state.
"f you set control property at this stage% its !alue might be o!erwritten in the ne&t e!ent.
-nit:
"n the Init e!ent of the indi!idual controls occurs first% later the Init e!ent of the 'age takes
place.
$his e!ent is used to initiali(e control properties.
-nit&omplete:
$racking of the )iewState is turned on in this e!ent.
Any changes made to the )iewState in this e!ent are persisted e!en after the ne&t postback.
%re8oad:
$his e!ent processes the postback data that is included with the re#uest.
8oad:
"n this e!ent the Page ob*ect calls the OnLoad method on the Page ob*ect itself% later the
OnLoad method of the controls is called.
$hus Load e!ent of the indi!idual controls occurs after the Load e!ent of the page.
&ontrol#$ents:
$his e!ent is used to handle specific control e!ents such as a Button control+s Click e!ent or
a TextBox control+s TextChanged e!ent.
"n case of postback:
"f the page contains !alidator controls% the Page.IsValid property and the !alidation of the
controls takes place before the firing of indi!idual control e!ents.
8oad&omplete:
$his e!ent occurs after the e!ent handling stage.
$his e!ent is used for tasks such as loading all other controls on the page.
%re!ender:
"n this e!ent the PreRender e!ent of the page is called first and later for the child control.
,sage:
$his method is used to make final changes to the controls on the page like assigning the
DataSourceId and calling the DataBind method.
%re!ender&omplete:
$his e!ent is raised after each control-s PreRender property is completed.
Sa$eState&omplete:
$his is raised after the control state and !iew state ha!e been sa!ed for the page and for all
controls.
!ender&omplete:
$he page ob*ect calls this method on each control which is present on the page.
$his method writes the control+s markup to send it to the browser.
>nload:
$his e!ent is raised for each control and then for the Page ob*ect.
33. 1rder to &all #$ent
1. )ontrols #alues and #ie state #alues can access from &age4&re-oad event of &age
-ife )ycle.
B. Session value can be access from beginning of &age4&reInit event of &age -ife )ycle.
!rder to call &age -ife )ycle (vent %"
A. &age4&reInit " -anding &age
B. &age4Init " /ser )ontrol
>. &age4Init " ,aster &age
C. &age4Init " -anding &age
D. &age4Init)omplete " -anding &age
P. &age4&re-oad " -anding &age
Q. &age4-oad " -anding &age
R. &age4-oad " ,aster &age
S. &age4-oad " /ser )ontrol
AM. &age4-oad)omplete " -anding &age
AA. &age4&re$ender " -anding &age
AB. &age4&re$ender " ,aster &age
A>. &age4&re$ender " /ser )ontrol
AC. &age4&re$ender)omplete " -anding &age
AD. &age4SaveState)omplete " -anding &age
AP. &age4/nload " /ser )ontrol
AQ. &age4/nload " ,aster &age
AR. &age4/nload " -anding &age
So, !n ,aster &age and /ser )ontrol only
A. &age4Init
B. &age4-oad
(vents fired not all events.
httpandler F #(tenstion "ased %reprocessor :
AS'../$ 0$$' handler is the process that runs in response to a re#uest made to an AS'../$ 1eb
application. $he most common handler is an AS'../$ page handler that processes .asp& files. 1hen
users re#uest an .asp& file% the re#uest is processed by the page through the page handler. You can
create your own 0$$' handlers that render custom output to the browser.
httpModule Event based Preprocessor :
An 0$$' module is an assembly that is called on e!ery re#uest that is made to your application. 0$$'
modules are called as part of the AS'../$ re#uest pipeline and ha!e access to life2cycle e!ents
throughout the re#uest. 0$$' modules let you e&amine incoming and outgoing re#uests and take
action based on the re#uest.
hen to use !""P handlers:
#$$ %eeds: $o create an SS feed for a 1eb site% you can create a handler that emits SS2
formatted 345. You can then bind a file name e&tension such as .rss to the custom handler.
1hen users send a re#uest to your site that ends in .rss% AS'../$ calls your handler to process
the re#uest.
&'a(e server: "f you want a 1eb application to ser!e images in a !ariety of si(es% you can
write a custom handler to resi(e images and then send them to the user as the handler+s
response.
hen to use !""P 'odules:
$ecur)t*: 6ecause you can e&amine incoming re#uests% an 0$$' module can perform custom
authentication or other security checks before the re#uested page% 345 1eb ser!ice% or handler
is called. "n "nternet "nformation Ser!ices 7""S8 9.: running in "ntegrated mode% you can e&tend
forms authentication to all content types in an application.
$tat)st)cs and lo(()n(: 6ecause 0$$' modules are called on e!ery re#uest% you can gather
re#uest statistics and log information in a centrali(ed module% instead of in indi!idual pages.
+usto' headers or %ooters: 6ecause you can modify the outgoing response% you can insert
content such as custom header information into e!ery page or 345 1eb ser!ice response.
Ma)n ,eatures:
$he "0ttp0andler and "0ttp4odule interfaces are the starting point for de!eloping handlers and
modules.
$he "0ttpAsync0andler interface is the starting point for de!eloping asynchronous handlers.
Custom handler and module source code can be put in the App;Code folder of an application%
or it can be compiled and put in the 6in folder of an application.
0andlers and modules de!eloped for use in ""S <.: can be used in ""S 9.: with little or no
change.
4odules can subscribe to a !ariety of re#uest2pipeline notifications. 4odules can recei!e
notification of e!ents of the 0ttpApplication ob*ect.

Das könnte Ihnen auch gefallen