PC Review


Reply
Thread Tools Rate Thread

ASP.Net Session programming for Newbie

 
 
James
Guest
Posts: n/a
 
      2nd Mar 2008
Hi there,

I'm just wondering if this is possible in Asp.net - I'm a newbie to Web
Programming:-)

I'm building this application that will hold a list Persons. A person can
have First Name, Last Name, Age, Gender etc.
What I want is, whenever a user browser comes onto my ASP.net page for the
very first time, I want a fresh/new list
of my Persons object to be given to the user - this is an Array of Person.
The user will then be able to change the list by deleting a few items from
the list.

The key thing I'm looking for, is when the browser window is closed, I want
ALL changes that were made to the person object/list/array to be discarded.
However,
if the user browser window is NOT closed, then the used may see changes made
to the list of persons. Please note that multiple users may log onto my
site at any given time,
and I want each user to have a Fresh list of persons object in which they
may manipulate.

My question to you all ASP.Net gurus are:

1.) Is this possible with using only objects loaded in memory?
2.) Will I need to use Session objects for this?
3.) What is the most simplistic way to implement such a page?


thanks,


 
Reply With Quote
 
 
 
 
Michael Nemtsev [MVP]
Guest
Posts: n/a
 
      2nd Mar 2008
Hello james,

j> 1.) Is this possible with using only objects loaded in memory?

Yep, just use the Cache class in for this, where u can store your data

j> 2.) Will I need to use Session objects for this?

yep, and you can control your data lifetime by the Session_End event, which
rise when user close browser. Take into account that it works only for the
InProc session mode

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


j> Hi there,
j>
j> I'm just wondering if this is possible in Asp.net - I'm a newbie to
j> Web Programming:-)
j>
j> I'm building this application that will hold a list Persons. A person
j> can
j> have First Name, Last Name, Age, Gender etc.
j> What I want is, whenever a user browser comes onto my ASP.net page
j> for the
j> very first time, I want a fresh/new list
j> of my Persons object to be given to the user - this is an Array of
j> Person.
j> The user will then be able to change the list by deleting a few items
j> from
j> the list.
j> The key thing I'm looking for, is when the browser window is closed,
j> I want
j> ALL changes that were made to the person object/list/array to be
j> discarded.
j> However,
j> if the user browser window is NOT closed, then the used may see
j> changes made
j> to the list of persons. Please note that multiple users may log onto
j> my
j> site at any given time,
j> and I want each user to have a Fresh list of persons object in which
j> they
j> may manipulate.
j> My question to you all ASP.Net gurus are:
j>
j> 1.) Is this possible with using only objects loaded in memory?
j> 2.) Will I need to use Session objects for this?
j> 3.) What is the most simplistic way to implement such a page?
j> thanks,
j>


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      2nd Mar 2008
"James" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi there,
>
> I'm just wondering if this is possible in Asp.net - I'm a newbie to Web
> Programming:-)
>
> I'm building this application that will hold a list Persons. A person can
> have First Name, Last Name, Age, Gender etc.
> What I want is, whenever a user browser comes onto my ASP.net page for the
> very first time, I want a fresh/new list
> of my Persons object to be given to the user - this is an Array of Person.
> The user will then be able to change the list by deleting a few items from
> the list.
>
> The key thing I'm looking for, is when the browser window is closed, I

want
> ALL changes that were made to the person object/list/array to be

discarded.
> However,
> if the user browser window is NOT closed, then the used may see changes

made
> to the list of persons. Please note that multiple users may log onto my
> site at any given time,
> and I want each user to have a Fresh list of persons object in which they
> may manipulate.
>
> My question to you all ASP.Net gurus are:
>
> 1.) Is this possible with using only objects loaded in memory?


Yes

> 2.) Will I need to use Session objects for this?


Need is a too strong a word. Its one reasonable way in this given scenario.

> 3.) What is the most simplistic way to implement such a page?
>


<script runat="server">
Person[] people;

protected void Page_Load(object sender, EventArgs e)
{
people== (Person[])Session["people"];
if (people== null)
{
people== GetInitialPeople();
Session["people"] = people;
}
}
</script>

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      2nd Mar 2008
"Michael Nemtsev [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello james,
>
> j> 1.) Is this possible with using only objects loaded in memory?
>
> Yep, just use the Cache class in for this, where u can store your data
>
> j> 2.) Will I need to use Session objects for this?
>
> yep, and you can control your data lifetime by the Session_End event,

which
> rise when user close browser. Take into account that it works only for the
> InProc session mode



How does session know when the user has closed the browser?
What constitutes a 'browser close', when allow windows/tabs currently
showing content from the site are closed or navigated to another site?

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Michael Nemtsev [MVP]
Guest
Posts: n/a
 
      3rd Mar 2008
Hello Anthony,

I wasn't clear enough - *shame me*

You can't control the Session_End by closing the browser - it doesnt activate
the Session_End at all

I meant that after the session timeout (setting in config) that event will
be called, or if you call Session.Abandon manually.
So, OP should rely either on that timeout or logout explicitly calling Session.Abandon

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


AJ> "Michael Nemtsev [MVP]" <(E-Mail Removed)> wrote in message
AJ> news:(E-Mail Removed)...
AJ>
>> Hello james,
>>
>> j> 1.) Is this possible with using only objects loaded in memory?
>>
>> Yep, just use the Cache class in for this, where u can store your
>> data
>>
>> j> 2.) Will I need to use Session objects for this?
>>
>> yep, and you can control your data lifetime by the Session_End event,
>>

AJ> which
AJ>
>> rise when user close browser. Take into account that it works only
>> for the InProc session mode
>>

AJ> How does session know when the user has closed the browser?
AJ> What constitutes a 'browser close', when allow windows/tabs
AJ> currently
AJ> showing content from the site are closed or navigated to another
AJ> site


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie to VBA Programming OD Microsoft Access Queries 1 2nd Jun 2009 12:23 PM
C# newbie on Wifi Programming Nighthawk Microsoft C# .NET 4 18th Apr 2008 01:50 PM
Newbie to programming =?Utf-8?B?QnJ5YW4=?= Microsoft Access 8 18th Nov 2005 12:27 AM
Newbie to programming =?Utf-8?B?QnJ5YW4=?= Microsoft Access 0 17th Nov 2005 03:16 AM
newbie programming Josh Ashcraft Microsoft Excel Programming 1 16th Jul 2003 08:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 PM.