Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Session in .NET 2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 26 Dec 2007 17:47 GMT
Hi,

I am new to .net. I have created a small web application using .net 2.0 in
vs2005, where the user logs in and adds content on their pages. The content
editing is done by integrating a wysiwyg editor (FCKEditor).

The problem is that sometime if the user spends too much time editing the
content and presses the update button, the session gets timed out and the
users looses all what he has been doing. In the old days of classic ASP, i
used to increase the Session.Timeout value to a high number. But how to do
it in .NET? I would like to know some best practice example of keeping the
user session alive in .NET.

Any help is appriciated.

Tnx.
Coskun SUNALI [MVP] - 26 Dec 2007 17:52 GMT
Hi,

You can achieve changing the timeout value in "web.config" file.

You have to find the node beginning with "sessionState" under "<system.web>"
node and change the value of "timeout" attribute. The value you set here is
based on "minute"s. So if its value is "20" then your session timeout value
is 20 minutes.

Signature

All the best,
Coskun SUNALI
MVP ASP/ASP.NET
http://sunali.com

> Hi,
>
[quoted text clipped - 12 lines]
>
> Tnx.
Mark Rae [MVP] - 26 Dec 2007 17:54 GMT
> In the old days of classic ASP, I used to increase the Session.Timeout
> value to a high number. But how to do it in .NET?

Same way:
http://msdn2.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstat
e.timeout(VS.80).aspx


> I would like to know some best practice example of keeping the user
> session alive in .NET.

Sessions time out for a reason, namely to reduce the amount of memory
overhead on the webserver. As the MSDN article below states, you should
really think very carefully before increasing the timeout value...
http://msdn2.microsoft.com/en-us/library/ms525473.aspx

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Scott Roberts - 26 Dec 2007 19:01 GMT
>> I would like to know some best practice example of keeping the user
>> session alive in .NET.
[quoted text clipped - 3 lines]
> really think very carefully before increasing the timeout value...
> http://msdn2.microsoft.com/en-us/library/ms525473.aspx

I'll second that. IMO, the "best practice" for using sessions is to pass
data from one page to another on a redirect. If you need to persist data
longer than a couple of seconds, I'd put it in a DB.
George Ter-Saakov - 26 Dec 2007 19:59 GMT
Read my article on codeproject for easy solution
http://www.codeproject.com/KB/aspnet/SessionForever.aspx

George.

> Hi,
>
[quoted text clipped - 12 lines]
>
> Tnx.
Scott Roberts - 26 Dec 2007 20:31 GMT
Nice work-around, but you still can't control when the asp.net worker
process re-cycles. Especially in a shared host environment.

> Read my article on codeproject for easy solution
> http://www.codeproject.com/KB/aspnet/SessionForever.aspx
[quoted text clipped - 17 lines]
>>
>> Tnx.
George Ter-Saakov - 26 Dec 2007 20:42 GMT
Ideally it should never recycle.
If you have a browser hitting the SessionRenew.aspx every 10 minutes then it
will not recycle due to inactivity.

If it recycles just because someone spiked CPU and hoster had to hit reset
button in shared hosting environment you doomed no matter what you do :)

But then if availability that important to you time to think about dedicated
server.

George.

> Nice work-around, but you still can't control when the asp.net worker
> process re-cycles. Especially in a shared host environment.
[quoted text clipped - 20 lines]
>>>
>>> Tnx.
Scott Roberts - 26 Dec 2007 20:54 GMT
> Ideally it should never recycle.

It does.

> If you have a browser hitting the SessionRenew.aspx every 10 minutes then
> it will not recycle due to inactivity.

Probably due to memory - from other hacks stuffing too much crap in their
session variables.

> If it recycles just because someone spiked CPU and hoster had to hit reset
> button in shared hosting environment you doomed no matter what you do :)

Indeed.

> But then if availability that important to you time to think about
> dedicated server.

Or not use sessions. :)
LVP - 27 Dec 2007 01:04 GMT
George Ter-Saakov,

quick question:

why can't you use a gif image instead of the gif-class something like:

......
......
document.images("renewSession").src = "/images/spacer.gif?par=" +
Math.random();
......
......

Does this work?   or Not ?

LVP

> Read my article on codeproject for easy solution
> http://www.codeproject.com/KB/aspnet/SessionForever.aspx
[quoted text clipped - 17 lines]
>>
>> Tnx.
George Ter-Saakov - 27 Dec 2007 15:35 GMT
The whole point of it was to silently renew .NET Session. For that you must
hit something that goes through .NET engine (usually .aspx page) every 20
minutes or your session will expire and removed due to inactivity and to
preserve server resources.

So how hitting spacer.gif is going to help?
The request does not go through .NET and will not renew session.

George.

> George Ter-Saakov,
>
[quoted text clipped - 34 lines]
>>>
>>> Tnx.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.