473,796 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.Net, Session_End, Sql Server 2003

When SQL Server 2003 is *not* configured in IIS5 isolation mode, is it true
that the Session_End event can not be depended on? If so, what is a good way
to clean up unmanaged resources that were created in abandoned user sessions?

Nov 18 '05 #1
8 1346
Session_End only fires for InProc sessions.

with out of proc session managers (such as sqlserver) , there are no
unmanaged resources to clean up, because the session objects are not
referenced (stored), only their serialization is stored (when you reqest
them from the session, they are deserialized into an object).

if your session objects have unmanaged resourecs (a really bad idea - though
generally they will not serialize and cannot be stored in session anyway),
then you should dispose of them after session serialization (say at
OnUnload - call base first).
-- bruce (sqlwork.com)


<ho******@nospa m.nospam> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
| When SQL Server 2003 is *not* configured in IIS5 isolation mode, is it
true
| that the Session_End event can not be depended on? If so, what is a good
way
| to clean up unmanaged resources that were created in abandoned user
sessions?
|
Nov 18 '05 #2
Hi Howard,

As Bruce has said, the Session_End event is only supported when we use the
InProcess Session. If you are using out of process session and do need to
control some certain resouce handles (stored in session) when the user's
session timeout or after some certain period. I think we can consider the
following means:
1.Use a cookie value (which set the expiration time as the Session Timeout
period) and check it in each comming request. When the cookie is
unvailable, that means the timeout and then do the release tasks and reset
the cookie.

2. Make use of the asp.net's application Cache which can store some
certain objects in memory and it can also send notify event when a certain
Cached object will be removed from the Cache collection(time out).

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #3
Steven,

Please help me understand this,

Session_End is only supported if we use InProc sessionState mode. If we use
SQLServer mode or StateServer mode, there is no Session_End event. But if we
use InProc sessionState with IS 5.0 isolation mode *not* enabled, then worker
process recycling causes Session_End to come at unpredictable times, making
is effectively useless.

Q: Is the above correct?

Presumably we should aim not to enable IS 5.0 isolation mode, since this is
included for backward compatibility only.

Q: Is this correct?

Checking a cookie value for each incoming request doesn’t help me, because
one of the problems that I am trying to solve is where the user closes their
browser, leaving the unmanaged resources that we created un-disposed. In our
case these unmanaged resources are necessary – we would have had to rewrite
hundreds of thousands of lines of existing code to eliminate the need for
them.

So therefore we should build a new solution that uses Cache plus timeout
notification. So my final question is:

Q: If I do not enable IS 5.0 isolation mode, and I use InProc sessionState
mode, will Session.Session ID be persisted correctly through worker process
recycling? Or do I have to use a cookie to persist SessionID, which I then
use to identify the Session resources that I have stored in Cache?
Nov 18 '05 #4
Hi Howard,

Thanks for your followup. As for the further question you mentioned, here
is the answers:

1 and 2 :

yes, on win2k3 IIS6 server, the IIS5 process isolation model is for
backward compatibility and it is recommended that we use the IIS6'S
application pool model. And the IIS6'S application pool isolation model can
help protect each application from being affected by other applications on
the same server(host each app in its own application pool)

3: The SessionId can't be persist after process recycle or application's
AppDomain restart. In fact, it'll even change when there is unhandled
exception occurs(Session will restart). Anyway, since the SessionID
maintaining is something invisible to us, I recommend that you implement
your own custom Identity if you need a unchanged token through appdomain/
process restart.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5
Steven,

Thanks -- I think I have it now.

--Howard
Nov 18 '05 #6
You're welcome Howard.

Good LUck!

Regards,

Steven Cheng
Microsoft Online Support

Nov 18 '05 #7
Since I'm don’t want to use IIS 5 emulation, I'll have to persist a
session-specific identifier and then use Cache to store data efficiently and
provide the equivalent of a session expiration event:

(1) Use StateServer mode or SQLServer mode or a cookie or a hidden field or
ViewState or query strings to persist my own unique pseudo session ID.

(2) Use the pseudo session ID to label any session-specific data I may store
in Cache, and to label any session-specific unmanaged resources.

(3) On each Page Load, retrieve my pseudo session ID and use it to access
session-specific data from Cache and session-specific unmanaged resources.

(4) Set my session-specific data in Cache to expire after a suitable timeout.

(5) Handle the cache data expiration event to clean up unmanaged resources
for the given session.

Is this correct?

Nov 18 '05 #8
Hi Howard,

I think this is ok. And another suggestion is you can still use the
SQLSESSION to store the orginal datas and the Cache object is just used to
help provide a session Timer which will notify us when a certain cache
object("Session ") will be expired so that we need to clear those objects in
the Session. Thus, we can avoid storing too many things in cache. How do
you think?

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
10804
by: Kenn Ghannon | last post by:
I've got an ASP.NET page with a counter subtraction routine in the Session_End method in the Global.asax.cs: protected void Session_End(Object sender, EventArgs e) { ulong curUsers; Application.Lock();
5
2806
by: Steve M | last post by:
Why are my sessions lasting so long? I have them set to 20 minute timeout in config file? The Session_End event is getting called an hour or more sometimes--well after the user has stopped interacting with my site. Anyone have any insight? Thanks in advance
7
4333
by: Imran | last post by:
Hi.., I tried to execute some code in the Sub Session_End in the Global.asax, but its not working. I am developing the asp.net application on Windows Server 2003 and IIS6. Tell me whats the problem. Imran
2
2382
by: Bonj | last post by:
Hi I have an ASP.NET application which implements a server-side charting solution, for this it needs to generate .gif files which are then sent to the browser via a literal which has its text set to "<img src=\" + graphfilename + \"/>. This is all working beautifully, however all these ..gif files are going to build up on the server and are going to need deleting. I tried putting some code in the Session_End function in global.asax, but...
6
2107
by: Annie | last post by:
Hi guys, I just want to do some clean up in the Session_End at Global.aspx. However, if the user closes the browser window that event is not fired. how can I call explicity protected void Session_End(Object sender, EventArgs e) when the user closes the browser window?
7
9287
by: Bruno | last post by:
We are attempting to automatically log users off from the Session_End event in global.asax and set some values on session_start. It is not a critical task, more of a housekeeping task so that we know if users have closed down their browsers without logging off first. However, although the code seems to run OK on our development servers (WinXP ASP.NET v. 1.1, SQL Server 2000, IIS6), they don't seem to be firing on the live server despite...
12
10712
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I am trying to maintain a list of people who are currently "online" in SQL. I do this by adding a simple entry to a simple PeopleOnline table whenever someone logs in to my site. If they manually log OUT of the site, I have no problem deleting them from the PeopleOnline table. But if they just close the browser, I was assuming I'd have to use the Session_End() event in Global.asax even though I know that this will only occur once the...
3
5786
by: Mufasa | last post by:
I have code in my session_start to create a temp directory for the session. On session_end it is supposed to delete the directory but doesn't seem to be firing. I've enclosed the code below. Can anybody give me any suggestions as to why Session_End seems to not be being fired? TIA - J.
5
2765
by: Ron J | last post by:
I would like to keep track of users when they are 'on'. On Session_Start I can write a DB record about them, but there does not seem to be session variable information during the Session_end event which I could use to update the record that they are logged out. This would also be nice to limit multiple logins. Is there a preferred way to track users login / logout /session time and multiple logins ? TIA
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10228
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.