Saturday, February 11, 2012

session and application in is a collection of objects.In that application is one.In all objects "application" is one object.In order to serve any resource from a web app first application should be loaded  and then resource will be serve.
When first user makes a request for any resource in the app'n then creates an app domain and loads the project inside it.When all sessions at server are lost and allocated application resources are also destroyed then run time can remove the appn.

when  a new user makes a request  session is used to uniquely identify uses in a a web app.session is created  whenever a new user  makes a request .Every session is Identified with a unique id called session Id.This id travels between requests and response
Every session create with a timeout 20 min by default
if user doesn't respond with in 20 minits then sever is going to all cleanup the session.alter this if user makes a request creates a new session and serves data in the session will be last
Session can also be closed pragmatically using Abandon() method of it

Developer can use application that represents an application and session which represents the sub process or session only in 2 ways
1.In the form variables for state management
2.In the form of events preforming actions and during their involved tasks.
Both variables and events are not mandatory for any web app but every project needs application and session level takes which are fulfilled only using events and also secured,higher level state provided with application and session variables only
public void application_Onstart()
public void session_Onstart()
Application["user"]=(int)Applciation ["Useronline"]+1;
public void session_OnEnd()
Application["useronline"]=(int)Applciation ["Useronline"]-1;
//under page load
protected void button _click(object sender,Event args e)
lblapp.Text="visitorno:"+Applcation["users"].To string();
lbl.Text="onlineno:"+Applcation["usersonline"].To string();
//In markup language
go  to web.config
<session state timeout="1"></session state>

we can change the time of half session pragmatically using  session.Timeout=n' and also in web.config markup using  session.timeout=1
By default session are also maintained internally using cookies which means we are dependent on browser again and our application may not run based on browser settings.Again session i can be managed cookies less.Cookie less means we are dependent on URI and using session state tag we can specify this settings

Post a Comment