IF WE TAKE THE EXAMPLE OF NEWS LIVE CRICKET
SCORE WEBSITES IN OUR SITED WE ALWAYS SEE THE UPDATED RESULTS. BUT BASICALLY IT IS NOT OWNSELF UPDATE,
SOME ONE IS UPDATING THEM . WE ALL OVER THE
WORLD WATCHING THEM
SO
WE CAN DO THIS BY SESSION
STATE MANAGEMENT
TECHNIQUE, BECAUSE SESSION ALWAYS CREATE A NEW SESSION ID OBJECT FOR A NEW
CLIENT
SO TO OVERCOME THESE TYPE OF PROBLEM WE USE APPLICATION STATE MANAGEMENT
TECHNIQUE
1.
HERE WE MANGE THE STATE AT
SERVER SIDE
2.
THIS IS AN SINGLE INSTANCE
IN FULL WEBSITED, IT IS LOADED IN MEMORY AT ONE TIME LIKE STATIC VARIABLE,
MEMORY IS AVAILABLE TILL YOUR PAGE IS OPENED WHEN YOU CLOSE IT THAN IT IS FREE
MEMORY
3.
APPLICATION OBJECT IS
CREATED WHEN THE SITE IS LOADED AND AN EVENT IF FIRED APPLICATION START,
4.
THIS OBJECT IS AVAILABLE TILL THE SITE IS
STOPPED, NO DUPLICATE COPY OF THIS OBJECT CAN NOT BE CREATED
5.
IF WE WANT TO ACCESS OUR INFORMATION ALL OVER
THE WORLD BY ANY CLIENT, SO ADD YOUR INFORMATION IN THIS OBJECT
PRACTICAL
ADD A GLOBAL APPLICATION CLASS
ADD NEW ITEM GLOBAL APPLICATION CLASS
<%@ Application
Language="C#"
%>
<script runat="server">
void
Application_Start(object sender, EventArgs e)
{
Application.Add("news", "arun is not
going in new york ");
}
void
Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void
Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void
Session_Start(object sender, EventArgs e)
{
// Code that
runs when a new session is started
}
void
Session_End(object sender, EventArgs e)
{
// Code that
runs when a session ends.
// Note: The
Session_End event is raised only when the sessionstate mode
// is set to
InProc in the Web.config file. If session mode is set to StateServer
// or
SQLServer, the event is not raised.
}
</script>
ON
DEFAULT.ASPX ( NEWS UPDATER PAGE)
}
protected void Button1_Click(object
sender, EventArgs e)
{
Application.Set("news", TextBox1.Text);
Response.Redirect("Default2.aspx");
Application.Add("news", TextBox1.Text);
}
On DEFAULT2. ASPX ( CLIENT SIDE TO SEE NEWS);
protected void Page_Load(object
sender, EventArgs e)
{
Response.Write(Application["news"].ToString() + "<br/>");
}
No comments:
Post a Comment