application and client session - where to code?

L

Likhith Areekkal

I am new to web programming.

I am trying to do an ASP .NET reservations application. I need to create
only one dataset and all the clients are supposed to use only that dataset.
Moreover, I need to create an array that can be accessed by all clients.

In short : As long as the application is running there should be only one
dataset and one array.

Earlier I have read about something about application session and client
session.

If I want array, dataset etc to last throughout the life of the application
and be common to all the clients who are accessing it..... which part of
the code should I create all this?

Given below is the skeletal version of my program. Could you please let me
know
1. For application session, in which the item is common to all clients,
which part of the code should I plug in all this?

2. If it is for client session - where the item is user specific and should
be destroyed after the user session is over - In which section of the code
should I build it?

Thank you.

Regards,
Li

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace RoomBookingApp
{
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
}// private void Page_Load
public void Calendar1_DayRender(object source, DayRenderEventArgs e)
{
} //public void Calendar1_DayRender

public void Calendar2_DayRender(object source, DayRenderEventArgs e)
{
} //public void Calendar2_DayRender

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
}
#endregion

private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
}

private void Calendar2_SelectionChanged(object sender, System.EventArgs e)
{
}
} //public class WebForm1 : System.Web.UI.Page
}//namespace RoomBookingApp
 
S

Steve C. Orr [MVP, MCSD]

Use the Application object, or if you want to get fancy you can use the
Cache object (which is similar but has extra features.)
You might want to fill the application object in your Application_OnStart
event (in your global.asax.cs)
Then you can retrieve the value whenever and wherever you need it, often
times in the Page_Load event.
 
J

John Saunders

Steve C. Orr said:
Use the Application object, or if you want to get fancy you can use the
Cache object (which is similar but has extra features.)
You might want to fill the application object in your Application_OnStart
event (in your global.asax.cs)
Then you can retrieve the value whenever and wherever you need it, often
times in the Page_Load event.

If you really need to keep a single copy of the data, then you should use
Application state.

Note, however, that Application state can be accessed by multiple requests
at the same time. You must synchronize access to this data. Take a look at
the SyncLock statement in VB.NET or the lock statement in C#.

John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top