Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

session Handling in asp.net

I am trying to find out how to destroy a ASP.NET session when the user navigates away from my site.I am using Global.ascx application file and use session_end event .Its working fine when i click logout button. But when i close browser directly its not using Global file after 20 minitues. i used in web.conig file as <sessionState mode="InProc" timeout="20"></sessionState>
Please help me
Augustine

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Session timeout defines when some session would be destroyed after some idle time.

If you want more control over sessions, you would need to use SQLServer mode, State Server mode, or a custom one taylored yourself.

I mean that, because, for example, SQLServer mode stores sessions in a standard SQL Server table, so, you can implement some SQL Server job, or schedule some task in Windows or in some Windows Service, so you can clean up sessions depending on your needs.

By the way, maybe you need to know that if you're using InProc, your sessions can be destroyed because IIS recycled application pool, or server got entirely restarted. And this isn't ending sessions, so the appropiate event and handler won't work in this scenario.

I repeat, if you need a better session management mode like ones I suggested you.


EDIT:

Check this page: http://aspalliance.com/520_Detecting_ASPNET_Session_Timeouts.2

You'll learn how to handle session timeouts better, since Session_End isn't called when a session expires, but when you call "Session.Abandon".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...