You are on page 1of 18

ARCHITECTURE OF ASP.

NET
ARCHITECTURE OF ASP.NET
Web Server
(.aspx)
HTTP REQUEST Aspnet_isapi.dll Asp.dll Web.config
ASP.net Runtime Env
Machine.config
(.asp)
App Domain HTTP RESPONSE
HTTP Handlers
Process Req
inet_info.exe
Aspnet_wp.exe
• • •

Inet_info.exe à identifies the request and submits the request to the aspnet_isa
pi.dll. Aspnet_isapi.dll à is a script engine which process the .aspx page Then
the script engine will submit the request to the ASP.NET runtime env. After veri
fying all the security issues of both machine.config and web.config then an AppD
omain will be defined for the request and after processing the request the respo
nse will be given to the client as HTTP response. Machine.Config à it is used to
maintain the complete configuration details of all the web applications registe
red on to the web server of ASP.net Web.Config à It is used to maintain the conf
ig details about a single web application. Where configuration details includes
security,database connectivity,state management,trace details of the web applica
tion,,authentication and authorization of the applications and globalizations Ap
pDomain:All windows appns run inside a process and these process own resources s
uch as memory and kernel objects and the threads execute code loaded into a proc
ess.Process are protected from each other by the OS. All these appns are run on
high isolation mode to work safely.The disadvantage of this is memory resources
are blocked.So to achieve this in a single process all the applications should b
e made to run which is good to an extent but the draw back is if one crashes all
other are effected. So in .net the code verification feature takes care that th
e code is safe to run. so asp.net each application runs its own application doma
in and therefore it is protected from other asp.net applications on the same mac
hine so it ignores the process isolation specified on IIS. HTTPHandlers:ASP.net
builds upon a extensible architecture known as HTTP runtime.This is responsible
for handling the requests and sending the response.It is upto an individual hand
lers such as asp.net or web service to implement the work done on a request.IIS
supports a low level API known as ISAPI. ASP.net implements a similar concept wi
th HTTP handlers.A request is assigned to ASP.net from IIS then ASP.net
• •



examines entries in the <httphandlers> section based on the extension of the req
uest to determine which handler the request should be send to. Features of asp.n
et • ASPX,ASP • Up gradation of ASP to ASPX is not required it supports side by
side execution and hence a request can be given from ASP to ASPX and vice versa.
• Simplified Programming Model • ASP.Net is a technology which can be implement
ed using any dot net language such as VB.net,C# etc and hence there is no requir
ement of HTML,JavaScript or VBScript to implement ASP.NET • Simplified deploymen
t • ASP.Net supports setup and deployment and hence the web app can be defined w
ith a web set up project which can be easily deployed on to the web server. Wher
e as for ASP CUTE FTP is used for deploying manually we have to upload. • Better
Performance • As the ASPX pages are complier based the performance of the web a
pplication will be faster then the ASP pages (as they are interpreter based) • C
aching • It is a process of maintaining the result or output of a web page tempo
rarily for some period of time .ASP supports Client Side caching where as ASP.Ne
t supports both client side and server side. • Security In ASP security is done
by IIS or writing the code manually. Where as ASP.Net is defined with built in s
ecurity features such as à windows authentication à Forms Authentication à Passp
ort Authentication à Custom Authentication More powerful data access • ASP.net s
upports ADO and ADO.Net as its database connectivity model which will be impleme
nted using the most Powerful OOP’S languages like VB.Net and C# and hence the da
tabase access using ASPX pages will be very powerful. Web services • It is a cod
e which will be published on the web which can be used by any applications writt
en using any language for an platform or device. Better session Management • Ses
sion Management in ASP.Net can be maintained using the database and as well cook
ieless sessions are also supported.It also supports enabling and disabling of se
ssion info within a web application. Simplified Form Validations • ASP.Net provi
des validation controls using which any type of client side validations are perf
ormed without writing any code. A web page is in 2 parts 1} Designing part (HTML
Content,Flash,Dreamweaver etc) 2} logic Part (sub programs and event procedures
and it has also your database interaction) ASP.Net supports 2 techniques for cr
eating web page 1) In Page Technique when you place design part code and logic p
art code with in a single file called as ASPX then it is called as inPage Techni
que.


• •



• •
2) Code Behind Technique when design part code is represented with in ASPX file
and logic part code is represented with in dll file then it is called as code be
hind technique. ASP Supports only In Page technique. DLL file is not a readable
file so it is secured.
Difference Between VB 6.0 & VB.NET 1) It is an object based programming 1) It is
an object oriented programming 2)Variables or member declarations are2)Here its
mandatory not mandatory 3)Uses Unstructured method for 3) Uses Unstructured / S
tructured methods for handling exceptions handling exception 4) Uses DAO, RDO, A
DO object 4) supports ADO and ADO.NET models models for database connectivity 5)
Uses Data projects as its default 5) uses crystal reports reporting tool 6)Uses
COM for language 6) Uses .net assembly for language interoperability interoperab
ility 7)Does not support multi threading 7)Does support multithreading 8)Uses DC
OM to support distributed 8)Uses .net remoting to support distributed technology
tech. 9) Supports web tech.,client side appns 9)It does not support web technol
ogy. or server side appns can be designed Note VB.net cant be used to design Cli
ent using VB Side / Server side appns but it can used as an implementing Lang fo
r asp.net Differences between C#.net & VB.net W.R.T C#.NET VB.NET DATA TYPES 1.U
nsigned Data Types 2.Strongly Typed Lang. 1.No Unsigned Data Types 2.It is not s
trongly typed
OOPS Concept
More concepts in C# Less Concepts here. u have interfaces, abstraction, No index
es in Vb.net and it has indexes limitations wrt interface Garbage collector, des
tructor,dispose.Automatic releasing of resources is not available.You have to ex
plicitly use dispose method
Memory Manag. Garbage Collector. Automatic releasing of resources is available.
It Boosts the performance.
Operator Overloading Pointers Auto XML Document.
Is available in C# Is available in C# Is available in C#
Is not available in VB.Net Is not available in VB.Net Is not available in VB.Net
Page Life Cycle Events
• • •
• •
Page_Init • This is fired when the page is initialized Page_Load • This is fired
when the page is loaded The difference between Page_Init and Page_load is that
the controls are guaranteed to be fully loaded in the Page_load.The controls are
accessible in the Page_Init event,but the ViewState is not loaded,so controls w
ill have their default values,rather than any values set during the postback. Co
ntrol_Event • This is fried if a control triggered the page to be reloaded (such
as a button) Page_unload • This is fired when the page is unloaded from the mem
ory
Types of Controls in ASP.Net • HTML SERVER • SYNTAX <INPUT TYPE=TEXT RUNAT=SERVE
R> • WEBSERVER CONTROLS Standard List Controls Validation Data Controls bound à
Radio Button Controls àlabel List àRequired field Controls àData Grid àTextbox à
Check Box Validator List àRange àData List àButton Validator àDropdown List àRe
peater àLink Button àCompare àImage Button àList Box Validator àCalendar àRegula
r àAdRotator Expression àPanel Validator àPlace Holder àCustom àTable Validator
àLiteral Control àValidation àRadio Button Summary àCheck Box àXML Common Syntax
for any web server control • <asp:controltype id=“name of the control” runat=“s
erver” ------------------------------//additional properties ></asp:controltype>
• To close syntax is “ / “ .
Misc Controls àCrystal Report Viewer control
• In order to set or get the value from any standard control text property shoul
d be used. • Eg: • <asp:label id=“lb1” runat=“server” text=“user name”></asp:lab
el> • <asp:button id=“lb1” runat=“server” text=“Login” /> Calendar Control • Usa
ge: It is used to place the calendar on the webform
– – – – – –
Note: Place the calendar control and right click on it and select autoformat to
provide a better look and feel for the control Calendar control can be considere
d as a collection of table cells Where every table cell will maintain the inform
ation about the days as a calendar day in the format of a link button control Wh
en ever the calendar days has to be customized based on the requirement of the u
ser DAYRENDER event should be used. Every event handler in the dot net tech will
accept two arguments 1st one being object and the 2nd one is eventArguements –
I.e. DayRender(Object,eventArguements) Event Arguments of DayRender event will p
rovide – e.cell -> to refer table cell – e.day -> to refer calendar day In order
to add a string value as a control to any other control “Literal Control” Shoul
d be used. –
ADO.NET CONNECTION ORIENTED MODEL DISCONNECTED ORIENTED MODEL CONNECTION ORI
ENTED MODEL Whenever an application uses the connection oriented model to inte
ract with the db then the connectivity between the application and the database
has to be maintained always. Whenever an user executes any statement other tha
n a select then command object can be binded directly to the application If th
e user executes a select statement then dataReader is used to bind the result to
the application. Disconnected Oriented Model When the user interacting with t
he db using this model then while performing the manipulations or navigations on
the data connectivity between the application and the database is not required
Note: When ever the data is been updated on to the database then the connectivit
y is required in the disconnected model.
DISCONNECTED MODEL
Application
Data View
DataSet
Database
This is available in client system
Data Adapter
Connection
Data Providers
Disconnected Model
Connection à it is used to establish the physical connection between the appli
cation and the database DataAdapter àit is a collection of commands which acts
like a bridge between the datastore and the dataset. Commands in DataAdapter
à
DataAdapter
Select Command Table Mappings Insert Command Update Command Delete Command
Update(Dataset Name[,DataMember])
Collection of all these commands is DataAdapter
Fill(Dataset Name[,DataMember])
DataAdapter DataAdapter can always be binded to a single table at a time. Wh
enever the dataAdapter is used then implicit opening and closing of connection o
f closing object will take place. If the dataAdapter is defined using a tool o
r a control then all the commands for the adapter will be defined implicitly pro
vided the base table with a primary key. If the base table is not defined with
a primary key then the commands relevant for update command and Delete command
will not be defined. Fill Method It is used to fill the data retrieved by the
select command of DataAdapter to the dataset. Update Method It is used to upda
te the dataAdapter with the data present in the dataMember of the dataSet. In ot
her words used to the update the database. DataSet It is an in memory represen
tation of the data in the format of XML at the client system. Points to rememb
er about DataSet: – It contains any no of datatables which may belong to the sam
e or different databases also. – If any manipulation are performed on the databa
se it will not be reflected on to the database. – Dataset is also considered as
a collection of datatables where a datatable can be considered as a DataMember.
– Dataset will not be aware of from where the data is coming from and where the
data will be passed from it. – Dataset supports establishing the relationship be
tween the datatables present in the dataset where the datatables might belong to
different databases also. DataSet is of 2 types à – Typed DataSet à when ever
the dataset is defined with the support of XML schema definitions then it is sa
id to be typed dataSet. – UnTyped DataSet à if the dataset is defined without th
e XML Schema Definition then it is said to be UnTyped DataSet. DataView It is
logical representation of the data present in the datamember of dataSet. Usage
à It is used to sort the data,filter the data or if the data has to be projecte
d in the pagewise then the dataView should be used. Command
It is used to provide the source for executing the statement I.e it used to spec
ify the command to be executed. Data Reader It is a forward and read only reco
rd set which maintains the data retrieved by the select statement.
ADO.NET
DISCONNECTED MODEL
CONNECTION ORIENTED MODEL
CONNECTION
Used if the statement is select statement
CONNECTION
DATA ADAPTER
COMMAND
DATA SET DATA VIEW
DATA READER
UI
UI
Used if the data has to be filtered, sorted or if the data has to be projected i
n page-wise
ADO.NET
SQL-SERVER
System.data.SqlClient
ORACLE
System.data.OracleClient
OleDB Providers
System.data.Oledb OleDB Connection OleDB Command
ODBC providers
System.data.ODBC ODBC Connection ODBC Command
SQL Connection
Oracle Connection Oracle Command
Oracle DataReader
SQL Command
SQL Datareader
OleDB Data Provider
ODBC DataProvider
SQL DataAdapter
Oracle DataAdapter
OleDB DataAdapter
ODBC DataAdapter
Syntax to define the Objectà – Dim objectName as new xxxConnection(“ProviderIn
fo”) where xx à can be either
SQL,Oracle,Oledb or ODBC Provider Info – To connect to MS-Access 2000 above ve
rsions à • Provider=microsoft.jet.oledb.4;datasource=databaseName.mdb – To conne
ct to SQL-Server db à • Provider=sqloledb.1;userid=sa;password=;database=databas
e name;datasource=servername • Note if SQL Connection is used then provider=prov
idername is not required. – To Connect to ORACLE à
• • • •
Provider = oracleoledb.oracle;userid=scott;pwd=tiger;datasource = servername OR
Provider = msdaora.1;……. Note if oracle connection is used then provider= provid
er name is not required.
To define Command Object à
Dim objectName as new xxxCommand([SQL Statement,connection object/Connection Str
ing]) To define DataReader à – Dim objectName as xxxDataReader To define Dat
aAdapter à – Dim objectName as xxxDataAdapter(Select Statement,<Connection Objec
t / Connection String>) – When ever the DataAdapter is defined using the above s
yntax then only the command relevant for the SelectCommand will be defined and i
n order to use the above commands they have to be build explicitly. To define
DataSet à – Dim objectName as new DataSet() To define DataView à – Dim objectN
ame as new DataView(datasetName.DataMemberName) Security in ASP.NET Asp.net pr
ovides various authentication methods to achieve security. They are: à – Forms
Authentication – Windows Authentication – Passport Authentication – Custom Auth
entication FORMS Authentication It is used to authenticate the user credential
s for Internet and Intranet applications. It is used to specify the authentica
tion mode to be used by the ASP.Net web application, to specify the login page i
nformation and to specify the format of the password to be used for providing ad
ditional security and also it acts like a database which maintains the user cred
entials information. Syntax to set the authentication <authentication mode=“Fo
rms”> <forms loginUrl = “login.aspx”> <Credentials passwordFormat =“SHA1/MD5/Cle
ar”> <User name =“_____” password=“____” /> _____________ _____________ any no o
f user information </credentials> </forms> </authentication> Authorization It
is used to allow or deny the users from accessing the webforms present in the we
b application. <authorization> <allow users=“__,__,__ / * “ /> <deny users
=“__,__,__ / * ”/> </authorization> Note: the tags and the attributes presen
t in the web.config is a case sensitive contents. –
In order to support Forms Authentication in ASP.Net the Dot Net Framework provid
es a base class library called as “System.web.security.Formsauthentication” Meth
ods to support Forms Authentication Authenticate :àIt is used to authenticate
if the provided information belongs to a valid user credentials or not.It return
s True if user info is valid else returns false. Syntax à authenticate(usernam
e,password) RedirectFromLoginPage à It is used to redirect to the requested we
bform from the login page if the provided user credentials belongs to a valid us
er. Syntax :- redirectFromLoginPage(username,booleanvalue) If specified TRUE
then the user info will be maintained as a permanent HTTP Cookie at the client
system and if FALSE is specified then user info will be maintained temporarily t
ill the browser is closed. HashPasswordForStoringInConfigFileàit is used to en
crypt the data using either SHA1 or md5 hash algorithms. Syntax à HashPassword
ForStoringInConfigFile (original Text,”md5/sha1”) SignOut à It is used to clea
r the session of the user which has been set the application User.identity.nam
e à returns the name of the user who has currently logged in. Windows Authenti
cation It is used to authenticate the user information based on the users regi
stered on the network. Note it is used to validate the users on the intranet e
nvironment. In web.config file à – <authentication mode=“windows” /> – <author
ization> <allow users/role =“DomainName/UserName,---” / roleName /> <deny users/
role = “DomainName/UserName,---” / roleName /> – </authorization> – Whenever the
user who has been currently logged in is present in the allow users list then a
ll the webforms can be accessed directly present in the web application.Else imp
licilty the webserver will project a dialog box to provide the user credentials
and allow the user to access the webforms provided the information belongs to a
valid user credentials. Types of Windows Authentication Basic Authentication à
if used as authentication type then the user credentials will be passed across
the n/w in cleartext Format. DigestAuthentication à it is a special authentica
tion type used to authenticate the Domain server users. – Note if the OS is not
a domain server then the Digest authentication type will be disabled in that sys
tem NTLM authentication à it is a default authentication type used by the wind
ows authentication where NTLM stands for Integrated Windows Authentication Steps
to set the authentication Type Start > RUN > inetmgr Right click on default
web site and select properties Click on Directory Security tab Click on the
Edit button present in the anonymous access and authentication control Check
on the different authentication types to be used To know the domain name of th
e system – [ In command prompt ]

C:\host Name – This gives the domain name
Passport Authentication If the same user credentials has to be maintained acro
ss multiple websites then passport authentication can be used. To achieve this
à – Install Microsoft Passport SDK – In web.config file • <authentication mode
=“passport”> – <passport redirectUrl =“internal /URL ‘ /> </authentication> Cust
om Authentication It is used to Validate the user credentials as per the requi
rement of the application. STATE MANAGEMENT IN ASP.NET • It is used to maintain
the state of the user across multiple pages. { OR } Web server maintaining clien
t information with out any connectivity is called as state management .This can
be implemented in various ways 1.View State [ Hidden field ] 2. Page Submission
3.Cookies 4.Session 5.Query String 6.Application 7. Cache
View State • It is the concept of persisting controls properties between request
s under post back implementation. • The view state will be implemented based on
hidden field. • The main advantage of view state will be 2 things • There is no
programming required from the developer so less burden on the developer. • The m
emory will not be allocated in the client system nor at in the webserver system.
It will be maintained as the part of the web page itself. • The problem with a v
iew state is there will be more amount of data transfer between client and web s
erver. • The view state can be controlled at the 3 levels à 1 } Control Level à
<Input = ….Enable viewstate=“true/false”> Note :à when it comes to sensitive dat
a it is not recommended to implement view state the sensitive data can be passwo
rd,credit card no, etc. • When you go with password type textbox the view state
will not be applicable implicitly. • 2} Page Levelà <%@ Pagedirective …..enable
viewstate=“true/false” > • 3 }Application Level à It requires web config It will
be applicable to all the web pages COOKIES • It is used to maintain the server
side information at the client system. { OR } A cookie can be defined as a small
amount of memory used by the web server on the client system.
Usage :à The main purpose of cookies will be storing perosonal information of th
e client,it can be username,pwd,no of visits,session id. • Cookies can be of 2 t
ypes:• Client Side Cookiesà If the cookie information is set using Javascript /
VbScript within an HTML page then it is said to be a client Side Cookies. • Serv
er Side CookiesàIf the cookie information is set using server side technology th
en it is said to be server side cookies.They are of 2 types: 1] Persistant Cooki
es ( Permanent Cookies ) 2] nonPersistant Cookies ( Temporary Cookies ) • 1] Per
sistant Cookies ( Permanent Cookies ) • When the cookie is stored on to the hard
disk memory then it is called as persistant cookie. • When you provide expires
than the cookie will be considered as persistent. • 2] nonPersistant Cookies ( T
emporary Cookies ) • When the cookie is stored with in the process memory of the
browser then it is called temporary cookies. Syntax • To set the cookies inform
ation Response.cookies(“cookie name”).value = value • To get or read the value f
rom a cookie variable = request.cookies(“cookie name”).value Points to remember
about cookies • Cookies information will be always be stored at the client syste
m only. • Cookies information are browser dependent ie the values of the cookies
set by one browser cant be read by other browser. • If the cookie information i
s set by IE then that info. Will be maintained in the memory of the browser itse
lf. • If the cookie information is set by Netscape Navigator then then informati
on will be maintained in “Cookies.txt” file. • There is no security for cookies
information. • Browsers has a capability to disable the usage of cookies within
it. • Note à if the browser disables the cookies in it and if any request for a
web form which contains the usage of cookies then the request will not function
properly. • User can change cookie content (or) user can delete Text file. • The
browser will support 20 cookies towards a single website . If we add 21st cooki
e then automatically the first cookie will be deleted. • A cookie can represent
maximum of 4kb of data. • To bind the cookie information to a specific domain à
response.cookies(“cookie name”).Domain = DomainName • To allow the different pat
hs of the same domain to access the cookie information à response.cookies(“cooki
e name”).path = “/path….” • note àthe default expiration time for the cookies is
30 min. • To set the expiration time for the cookie info à response.cookies(“co
okie name”).expires = dateTime • To secure the cookie information à response.coo
kies(“cookie Name”).secure = booleanValue Session When client makes a first requ
est to the application,ASP.net runtime will create a block of memory to the clie
nt in the web server machine.This Block of memory is called as session memory.Th
is memory will be unique to the client with the Time Out of 20 min by default.He
re
timeout indicates from the last access of client request not from creation of co
okies.Cookie can represent only plain text not an object but session memory has
an object. Differences between Session & Cookies Session Cookies It will be main
tained in the web It will be maintained in the client server system.So it is cal
led as system. So it is called as client server side management side state manag
ement. Session can represent objects Cookie can represent plain text More securi
ty for data Accessing will be slow Less security for data. Accessing would be fa
ster.
Limitations of sessions in ASP • In ASP client info is maintained by the server
using its sessionID irrespective of session object usage. • Sessions in ASP are
always cookies based. • Enabling and disabling of sessions are not supported in
ASP Sessions in ASP.Net • Sessions in ASP.net can be àCookies Based ( Default )
àCookieless àIt can be stored in database also (SQL Server) • Syntax à To get se
ssion Info Session(“variable”) = value à To Read / Get value Variable = session(
“variable”) • Note:à • If the value assigned to the session variable is a charac
ter data then the info will be maintained in the contents collection of the sess
ion object • If the value assigned to the session variable is an object then tha
t information will be maintained in the static object collection of session obje
ct. • By default session state for the application will be true and hence the co
ntents of the session object can be used. • In order to disable the session obje
ct usage in the web form then “enable session state” attribute of the page direc
tive should be set as false. • In the page directive I.e go to the HTML view and
in that page directive at the start of the page make the enable session state a
s = false. • Syntax à <% @ page language =“vb” enablesessionstate=“false”…….%> S
ession Object • Session Object à this object can be used to access session memor
y from asp.net web page. The following are the methods à 1. Add(key,value) where
key à String and value à object 2.Remove(key) 3.Abandon() à to close the sessio
n 4.SessionId 5.TimeOut Points to remember about Session


• •
• • • •
The default session timeout is 20mins To set the session timeout session.timeout
= minutes (à specify the min) {OR} In web.config we have tag available for sess
ion <sessionstate mode=“Inproc” cookieless=“false” timeout =“minutes” /> Note :
the default sessionstate uses cookies for maintaining the data or info. To defin
e a session as cookie-less then in web.config: <sessionstate mode=“Inproc” cooki
eless=“false” timeout=“20” /> note:à once the sessionstate is set to cookieless
then the sessionInfo or the sessionID will be appended to the URL for each and e
very webform present in the web application. In order to retrieve the sessionID
of the client session.sessionID should be used. In order to maintain the session
info. On the SQL server database then in web.config: <sessionState mode=“sqlser
ver” stateconnectionstring=“tcpid=127.0.01:42424” sqlconnectionstring= “______(c
ompletepath”) cookieless=“false” timeout=“20” /> In order to clear the session v
ariable present in the session object contents collection then “session.contents
.remove(“sessionvariable”)” In order to clear all the items present in the conte
nts collection then “session.contents.removeall()” should be used. In order to k
ill the session of the user then “session.abandon()” method should be used. To d
isable the session information for a specific webform then enablesessionstate=“f
alse” should be set for the page.
Application It is used to maintain the state of all the users accessing the we
b applications. When the first client,first request comes to the application w
eb server will allocate a block of memory this is called as application memory.
The application memory will not have any life time. Application object can b
e used to access application memory from asp.net web page Application object c
onsists the following methods à 1} Add (key,value) {or} Application(“var”) = val
ue 2} Remove(key) 3} lock() 4} unLock() note à the lock and unlock are not avail
able in session,but available in application . To set:à Application (“variable
”) = value To read:à variable = application(“variable”) ProblemàIf the appli
cation object is not maintained properly then it will result in Data Inconsisten
cy. When ever the application variables are used in the webform then it is man
datory to Lock the application contents. To do:à Application.Lock() If appli
cation.lock() method is encountered while processing the webform then all the ot
her requests which uses the application contents will not be blocked till the we
bform processing is completed. Lock is used to allow only one client at a part
icular time.
Each client requests to the webserver is considered as thread.webserver will a
llocate equal processor time to all the threads.In this aspect more then one thr
ead can manipulate application memory data,this may lead to improper result to a
void this it is recommended for synchronisation of threads. Synchronisation is
nothing but allowing user one at a particular time. The synchronisation of th
reads can be implemented using lock and unlock methods. Global.asax It’s a col
lection of events where the code written in those events will be executed implic
itly whenever the relevant event takes place. In order to work with the applic
ation and the session objects and to handle the events in a proper manner “globa
l.asax” file should be used. Application_Start à the code written in this even
t will be executed only once whenever the application has been encountered with
the first request Session_Start à the code written in this event will be execu
ted when ever a new session for the user starts. Application_BeginRequest à th
e code written in this event will be fired when ever any webform present in the
webapplication is loaded. Application_Authenticate à the code written in this
event will be executed when even the authentication takes place. Application_e
rror à the code written in this event will be executed when ever any error or ex
ceptions occurs at webforms present in the web application. Note à in order to g
et the last error which has been generated on the webform “server.getLastError()
” should be used. Session_End à the code written in this event will be execute
d whenever the session of the user ends Application_End à the code written in
this event will be executed whenever the web application is closed. Caching • It
is used to maintain the result of the webform temporarily for a specific period
of time. • ASP supports client side caching. • Where as ASP.net supports both c
lient side caching and server side caching.
Client Side Caching
• If the cache page is maintained at the client side it is said client side cach
ing.
C1 C2 C3 Server Proxy Server
Cache page
Web server Gateway Modem ISP
• •
To Set this :à Response.cachecontrol = public Advantage :à only the people who a
re connected in the network they will be getting the page faster.
Server Side Caching • then it is said to be server side caching. • Points to rem
ember • Caching should be used if and only if the following properties are satis
fied 1} The contents of the webform should not be modified at least for a specif
ic period of time. 2} The no of clicks for the webform present in the web applic
ation should be more. Types – Server side caching • 1~~~> Page – Output Cache •
2 ~~~> Page – Fragmentation (Partial) Cache • 3 ~~~> Data Cache. Page – Output c
ache when ever the complete result of the webform or the o/p of the webform is m
aintained as a cache page at the webserver then it is said to be a page-output c
ache. • To Setà <% @ outputcache duration=“seconds” varybyparam=“none/controlNam
e/VariableName” %> • VaryByParam à it is used to set an individual cache page fo
r every distinct value assigned for the control or the variable assigned to the
varybyparam. {example 1} • Page Fragmentation Cache à It is used to maintain onl
y a partial page contents as a cache contents on the web server • To achieve thi
s Page Fragmentation à à Define a web custom control à Set the cache for the cus
tom control à use the web custom control on the web form. Web User Control • Web
User Control à It is used to design a web control which can be used by an webfo
rms of ASP.net • To design à Project à Add web user control • To use the web use
r control on the web form à • 1st method à select the name of the web user contr
ol file in the solution explorer and then drag drop that file on to the web form
. • 2nd method à 1} register the web user control as a tag prefix in the webform
:à for eg : <% @ register tagprefix = “UC1” tagname=“webusercontrol” src=“webuse
rcontrol2.aspx” %> 2} place the web user control as a normal control on the webf
orm <uci:webusercontrol2 id=“wuc2” runat=“server” /> Data Cache • It is used to
maintain the data present in an object as a cache information ,where the object
can be dataset,datview or datareader.

Note:à once the data is been set as a cache then if the data is modified or mani
pulated at the database level there wont be any reflection at the data present i
n the cache.
Tracing It is used to trace the flow of the application. It is of 2 types à
Application level tracing à If this is used then for all the webforms present
in the web application the trace details or information will be provided. Page
level tracing à if used then only specific web form the trace details will be s
et. Note à if the application level and page level tracing information is set
then the preference will be given to the page level tracing only. To set appli
cation level tracing à in web.config à <trace enabled=“true” requestlimit=“10” p
ageoutput=“true”…../> Methods to support tracing Trace.write à It is used to w
rite the data on to the trace information. Trace.warn à it is used to write th
e data on to the trace information using red as its fore color such that the inf
ormation will be highlighted at the trace info section. To set page level trac
e info in page directive tag :à <% @ pagelanguage=“vb” trace=“true” %>

You might also like