什么是会话变量的选择吗? [英] what are the alternatives of SESSION VARIABLES?

查看:155
本文介绍了什么是会话变量的选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是开发大型Web应用程序中的会话变量的局限性。
还什么是会话变量的最好的替代

What are the limitations of the session variable in developing large web application. Also what are the best alternatives of the session variables.

请提供给我在 session变量的替代品

Please provide me the alternatives of SESSION VARIABLES

推荐答案

要了解不使用会话的优势,你必须了解会议的工作方式。

To understand the advantages of not using sessions, you have to understand how sessions work.

在默认设置中,


  • 会话通过在用户的浏览器Cookie设置标识和

  • 会话数据存储在内存中的Web服务器

当用户向服务器发送一个请求,会话cookie被发送沿。它包含服务器使用来定位特定用户的会话数据的标识符。

When the user sends a request to the server, the session cookie is sent along. It contains an identifier which the server uses to locate that particular user's session data.

您可以将ASP.NET配置为

You can configure ASP.NET to


  • 使用查询参数,而不是cookies存储会话标识符

  • 会话数据存储在数据库中(有会话数据的中央数据存储,如果你有服务站点的多个服务器尤为重要)

现在禁用会话状态的优点:

Now for the advantages of disabling session state:


  1. ASP.NET使得访问会话数据线程安全的连载请求。这意味着,当启用会话状态时,ASP.NET拒绝服务来自同一用户的并发请求。这是特别的一个问题,当用户的浏览器使得很多Ajax请求的。这个问题可以通过标记会话状态只读的,你不需要更新请求得到缓解。

  2. 当请求时,ASP.NET有抓取会话数据,并且它具有的请求结束时将数据写回。这可能不是一个大的问题,如果会话状态被存储在存储器,但是如果数据被存储在中央数据库中,这可能会导致严重的性能问题。

不用说,这些问题是由存储大量数据的大量用户的恶化。

Needless to say, these issues are exacerbated by storing large amounts of data for a large number of users.

有关更多信息,请参阅


  1. ASP.NET会话状态概述

  2. 快速,可扩展和安全会话状态管理为Web应用程序

  1. ASP.NET Session State Overview
  2. Fast, Scalable, and Secure Session State Management for Your Web Applications

(即最后一篇文章是有点过时,但仍然是一个良好的阅读)。

(that last article is a bit dated, but still a good read).

替代


  • 如果可以的话,完全避免会话状态。

  • 如果你绝对必须与用户数据相关联,使用HTTP的机制,使浏览器携带的cookie或者查询参数的数据(这是整个REST的运动部分是什么)。

希望这有助于。

这篇关于什么是会话变量的选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆