我怎么能存储会话在MVC3 SQL服务器 [英] How can I store session in SQL server in MVC3

查看:93
本文介绍了我怎么能存储会话在MVC3 SQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要存储在ASP.NEt MVC3 SQL Server会话,因为我想分享的会话和两个应用程序之间的一些数据。我怎样才能做到这一点。

I want to store session in SQL Server in ASP.NEt MVC3 because I want to share session and some data between two application. How can I achieve this.

推荐答案

通过设置 <的sessionState> 在你的web.config:

By setting the <sessionState> in your web.config:

<sessionState 
    mode="SQLServer"
    sqlConnectionString="data source=SQLServerName;user id=<username>;password=<strongpassword>"
/>

这假定您已经使用的 ASPState的数据库首先在目标数据库服务器上美国/库/ ms229862.aspx> aspnet_regsql.exe的 实用程序:

This assumes that you have created the ASPState database first on the target database server using the aspnet_regsql.exe utility:

aspnet_regsql.exe -S SQLServerName -E -ssadd -sstype p

请确保您运行从正确的NET框架目录此实用程序。例如,如果您使用的是.NET 4.0,这将是 C:\\ WINDOWS \\ Microsoft.NET \\框架\\ v4.0.30319 \\

Make sure that you run this utility from the correct .NET framework directory. For example if you are using .NET 4.0 this would be c:\Windows\Microsoft.NET\Framework\v4.0.30319\.

一旦数据库SQL服务器上创建的,你可以指定一个用户帐户来访问它,它是你应该在连接字符串中指定该用户帐户。

Once the database is created on the SQL server you could assign an user account to access it and it is this user account that you should specify in the connection string.

这篇关于我怎么能存储会话在MVC3 SQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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