`
mybwu_com
  • 浏览: 179028 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

Asp.net Session study

 
阅读更多

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:

  1. Process is slow due to serialization and de-serialization.
  2. 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:

  1. Session data not affected if we restart IIS.
  2. The most reliable and secure session management.
  3. It keeps data located centrally, is easily accessible from other applications.
  4. Very useful in web farms and web garden scenarios.

Disadvantage:

  1. Processing is very slow in nature.
  2. need serialization .before exchanging session data between application and sql sever .
  3. 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:

  1. We can use an existing table for storing session data.
  2. It's separate from IIS, so restarting the web server does not have any effect on session data.
  3. 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.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics