如何在数据库中存储和访问会话 [英] How to store and access sessions in the database

查看:56
本文介绍了如何在数据库中存储和访问会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP .NET Sessions做一个高级项目,我想知道:

I'm doing an advanced project with ASP .NET Sessions, I would like to know:

A)我到底要添加什么到我的web.config中,才能将整个会话写入数据库服务器.

B)启用会话后,会话将存储在哪个表中?到目前为止,我只知道默认值为"TempDB".

推荐答案

您可以在此MSDN 文章.转到 SQL Server模式

这是必需的配置

<configuration>
  <system.web>
    <sessionState mode="StateServer"
      stateConnectionString="tcpip=SampleStateServer:42424"
      cookieless="false"
      timeout="20"/>
  </system.web>
</configuration>

这里,您具有有关会话信息的存储位置以及如何更改默认位置的一些详细信息.有关更多详细信息,请检查

Here you have some details about where the session information is stored and how to change the default location. For more details, check this article as Andre Calil suggested.

默认情况下,Aspnet_regsql.exe工具将创建一个名为ASPState的数据库,其中包含支持SQLServer模式的存储过程.默认情况下,会话数据本身存储在tempdb数据库中.您可以选择使用-sstype选项更改会话数据的存储位置

By default, the Aspnet_regsql.exe tool will create a database named ASPState containing stored procedures that support SQLServer mode. Session data itself is stored in the tempdb database by default. You can optionally use the -sstype option to change the storage location of session data

这篇关于如何在数据库中存储和访问会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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