如何使用会话状态模式:SQL Server 与 VS2010
我想使用该会话状态,因为 Inproc 不可靠。我需要在配置文件中设置该模式,但不知道如何......有人可以帮助我吗?
我从 aspnet_regsql 工具得到的异常
xception:
无法连接到 SQL Server 数据库。
失败详细信息
System.Web.HttpException (0x80004005):无法连接到 SQL Server 数据库。 ---> System.Data.SqlClient.SqlException (0x80131904): 建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接) 在System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection) 在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 在System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,SqlInternalConnectionTds connHandler,布尔ignoreSniOpenTimeout,Int64计时器Expire,布尔加密,布尔trustServerCert,布尔integratedSecurity) 在System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,字符串newPassword,布尔ignoreSniOpenTimeout,TimeoutTimer超时,SqlConnection owningObject) 在System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,字符串newPassword,布尔redirectedUserInstance,SqlConnection owningObject,SqlConnectionString connectionOptions,TimeoutTimer超时) 在System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject,TimeoutTimer超时,SqlConnectionString connectionOptions,字符串newPassword,布尔redirectedUserInstance) 在System.Data.SqlClient.SqlInternalConnectionTds ..ctor(DbConnectionPoolIdentity身份,SqlConnectionString连接选项,对象providerInfo,字符串newPassword,SqlConnection owningObject,布尔redirectedUserInstance) 在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 选项、对象 poolGroupProviderInfo、DbConnectionPool 池、DbConnection owningConnection) 在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection、DbConnectionPool 池、DbConnectionOptions 选项) 在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) 在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) 在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) 在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection 外连接,DbConnectionFactory 连接工厂) 在 System.Data.SqlClient.SqlConnection.Open() 在System.Web.Management.SqlServices.GetSqlConnection(字符串服务器,字符串用户,字符串密码,布尔信任,字符串连接字符串) 在System.Web.Management.SqlServices.GetSqlConnection(字符串服务器,字符串用户,字符串密码,布尔信任,字符串连接字符串) 在 System.Web.Management.SqlServices.SetupApplicationServices(字符串服务器、字符串用户、字符串密码、布尔信任、字符串连接字符串、字符串数据库、字符串 dbFileName、SqlFeatures 功能、布尔安装) 在 System.Web.Management.ConfirmPanel.Execute()
I want to use that session state, because Inproc is unreliable. I need to set that mode in the config file, but dont know how.. can someone help me?
Exception i got from aspnet_regsql tool
xception:
Unable to connect to SQL Server database.
Details of failure
System.Web.HttpException (0x80004005): Unable to connect to SQL Server database. ---> System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
at System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install)
at System.Web.Management.ConfirmPanel.Execute()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您没有在 sql 上创建会话数据库,您需要首先运行一个工具来使用 aspnet_regsql.exe 工具。
有关此工具的更多信息: http://msdn.microsoft.com /en-us/library/ms229862(VS.80).aspx
其次,您可以使用集成安全性进行连接,而不使用用户名和密码。
在连接字符串上设置
此内容请转到 system.web
更多详细信息。如果您转到网络目录,您会看到带有 .sql 扩展名的文件列表。其中之一是InstallSqlState.sql,这是该工具运行来创建数据库的一个。如果你打开它,你可以看到正在运行的内容。
If you do not have create on sql the session database you need first to run a tool to create it using the aspnet_regsql.exe tool.
More for this tool: http://msdn.microsoft.com/en-us/library/ms229862(VS.80).aspx
Second you can connect using Integrated security and not use user name and password.
Set this on connection strings
This go to system.web
Some more details. If you go to your net directory you see a list of files with .sql extention. One of this is the InstallSqlState.sql, this is the one that the tool runs to create the database. If you open it you can see what is run.
您还可以使用状态服务器。您可以按照此处的分步指南
http://dotnetguts.blogspot.com/2009/06/steps-for-session-inproc-mode-to.html
我希望你知道每个会话状态的优点/缺点这样您就可以为您的应用选择合适的产品。
You can also use a StateServer. You can following the step-by-step guide here
http://dotnetguts.blogspot.com/2009/06/steps-for-session-inproc-mode-to.html
I hope you know the pro/cons of each of the session states so you can choose the right one for your application.