简体   繁体   English

Windows Azure上具有多个实例的会话变量

[英]Session variables with multiple instances on windows Azure

I'm working on an MVC3 Project and SQL Azure database. 我正在研究MVC3项目和SQL Azure数据库。 when i deploy more than 1 instance i get some problems with the sessions variables. 当我部署多个实例时,会遇到会话变量的一些问题。

To be more clear, i store the results of a table in a session variable and i pass the results to the model, the user can modify and manipulate the data until he clicks the "save" button. 为了更清楚,我将表的结果存储在会话变量中,并将结果传递给模型,用户可以修改和操作数据,直到他单击“保存”按钮。

When the user clicks "Save" i obtain the new values from the model and pass them to the BLL and DAL layers for update the database. 当用户单击“保存”时,我从模型中获取新值并将它们传递给BLL和DAL层以更新数据库。

I dont know if this is the right solution !! 我不知道这是否是正确的解决方案! but the client won't hit the database on every data changing. 但是客户端不会在每次数据更改时都访问数据库。

Help please. 请帮助。

The problem you're experiencing is due to the fact the session data is stored locally on a server (this is called InProc by ASP.NET). 您遇到的问题是由于会话数据本地存储在服务器上(这被ASP.NET称为I​​nProc)。 When you're using multiple instances this data isn't shared between the instances. 当您使用多个实例时,实例之间不会共享此数据。 In order to accomplish this you have a couple of choices: 为了实现这一目标,您有两个选择:

  • Store the session data in a SQL Azure database. 将会话数据存储在SQL Azure数据库中。
  • Store the session data in Azure's table storage. 将会话数据存储在Azure的表存储中。
  • Store the session data in Azure's caching service (probably the fastest, but also the most expensive). 将会话数据存储在Azure的缓存服务中(可能是最快的,但也是最昂贵的)。

Here's some more info: http://acloudyplace.com/2012/02/managing-session-state-in-windows-azure-what-are-the-options/ 这里有更多信息: http//acloudyplace.com/2012/02/managing-session-state-in-windows-azure-what-are-the-options/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM