<add name="SqlState" connectionString="Data Source=localhost;DataBase=AnyNameOfServerState;Integrated Security=True" providerName="System.Data.SqlClient"/>
<sessionState mode="SQLServer" sqlConnectionString="SqlState" allowCustomSqlDatabase="true" cookieless="false" timeout="20"/>
我尝试将上述两行放入我的 web.config 文件中,然后运行代码:我得到了:
System.Data.SqlClient.SqlException:
MSDN 给了我以下提示:
验证您是否使用有效凭据进行连接。
Make sure that the credentials you are supplying are valid. For more information, see How to: Access SQL Server Using Predetermined Credentials.
验证服务器名称是否正确以及服务器是否正在运行。
Make sure that you are using the correct server name, and that the server can be reached.
但我不知道如何关注它们,因为这是我第一次在 SQL 模式下使用 Session,...
更多注意:我需要临时会话几秒钟,我需要保存我所拥有的动态控件的状态。我认为我可能会遇到该状态模式的问题是,如果它与用户一起拖动 20 分钟,从而减慢我的应用程序的速度。我应该改用 viewState 吗?