Session Start/End
in global.asax :
void Session_Start(object sender, EventArgs e) {
// Code that runswhen a new session is started
}
void Session_End(object sender, EventArgs e) {
// Code that runswhen a session ends.
}
Session Mode:
1. InProc
Advantage:
1. As stored inmemory , so very fast to retrieve and store .
2.Easy to implement
3.no need serialization
Disadvantage:
1.session data depends on application pool and worker process , if one of them is not working properly , all session data is gone
2.more user will have performance problem
3.can not use in web garden or web farm deploy strategy .
when use:
less user and small application , and whenever no need web garden or web farm deploy strategy .
2.StateServer (Need AspNet_SessionStateService On)
Advantage:
1.It keeps data separate from IIS so any issues with IIS will not hamper session data.
2.It is useful in web farm and web garden scenarios.
Disadvantage:
- Process is slow due to serialization and de-serialization.
- State Server(Session State Service) always needs to be up and running.
when use:
When Need web garden or web farm deploy strategy canconsider this session mode.
3.SqlServer
Advantage:
- Session data not affected if we restart IIS.
- The most reliable and secure session management.
- It keeps data located centrally, is easily accessible from other applications.
- Very useful in web farms and web garden scenarios.
Disadvantage:
- Processing is very slow in nature.
- need serialization .before exchanging session data between application and sql sever .
- have to take care of SQL Server. It should be always up and running.
when use:
1.we need to give a high security to session data
2.need to deploy as web garden or web farm
3.need to share session between different applications
4.Custom
Advantage:
- We can use an existing table for storing session data.
- It's separate from IIS, so restarting the web server does not have any effect on session data.
- We can create our own algorithm for generating session ID.
Disadvantage:
1.Processing of data is very slow.
2.Creating a custom state provider is a low-leveltask that needs to be handled carefully to ensure security.
when use:
It is always recommended to use a third party providerrather than create your own.
分享到:
相关推荐
asp.net session的应用
ASP.NET的 Session 详解
ASP.NET Session的七点认识
【ASP.NET编程知识】ASP.NET session.timeout设置案例详解.docx
ASP.NET源码——[电子商务].Net Session购物车示例.zip
ASP.NET 中 Session 实现原理浅析 如 session的说明 使用等等
详细介绍.net 项目session存入mysql数据库,有完整demo 参考地址: http://www.codeproject.com/Articles/633199/Using-MySQL-Session-State-Provider-for-ASP-NET
在后台应用程序中设置:Session.Timeout = 1; 注意:1、此方法可以设置在一个公共的页面中,然后直接调用即可。 2、时间是以分钟为单位的 方法二: 在Web.config中设置: 在<system></system>中写入...
ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP.NET入门经典ASP...
在asp.net中使用session常见问题集锦
[电子商务].Net Session购物车示例_sessiongwc(ASP.NET源码).rar
用ASP.NET三层架构写的登录实例,大家参考! 表:Login 属性:LoginName varchar(50) LoginPassword varchar(50)
ASP.NET中简单的Session、Application、Cookie的小例子
内容很简单 简单到只告诉你怎么操作来实现 方便大家学习
一个基于 ASP.Net的进行Session 处理的高级技巧程序例子代码。
ASP.NET 参考手册 在 W3School,我们提供完整的 ASP.NET 参考手册,其中包括内建对象和组件,以及它们的属性和方法。 ASP.NET 实例 ASP.NET 实例 一系列的 ASP.NET 实例。 内容目录 ASP.NET 简介 本章解释 ASP.NET...
关闭页面时清空Session (ASP.net ) (已实现)
asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程asp.net教程...
ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP.net实战项目ASP...