Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
CẢNH BÁO Không sử dụng các file cấu hình web trong Ví dụ 28,16 mà không sửa đổi các giá trị của decryptionKey cả và các thuộc tính validationKey. Những giá trị phải được bí mật. Bạn có thể sử dụng trang GenerateKeys.aspx thảo luận trong Chương 27, "Sử dụng ASP NET thành viên.," Để tạo ra giá trị mới cho những thuộc tính này. | 1294 CHAPTER 28 Maintaining Application State WARNING Don t use the web configuration file in Listing 28.16 without modifying the values of both the decryptionKey and validationKey attributes. Those values must be secret. You can use the GenerateKeys.aspx page discussed in Chapter 27 Using ASPNET Membership to generate new values for these attributes. After you complete these configuration steps Session state information is stored in the ASP.NET State Server automatically. You don t need to modify any of your application code when you switch to out-of-process Session state. Configuring SQL Server Session State If you want to store Session state in the most reliable way possible you can store Session state in a Microsoft SQL Server database. Because you can set up failover SQL Server clusters Session state stored in SQL Server should survive just about anything including a major nuclear war. You must complete the following two steps to enable SQL Server Session state 1. Configure your database to support SQL Server Session state. 2. Configure your application to use SQL Server Session state. You can use the aspnet_regsql tool to add the necessary tables and stored procedures to your database to support SQL Server Session state. The aspnet_regsql tool is located in the following path WINDOWS Microsoft.NET Framework jversionj aspnet_regsql.exe NOTE If you open the Visual Studio Command Prompt you don t need to navigate to the Microsoft.NET folder to use the aspnet_regsql tool. Executing the following command enables SQL Server Session state for a database server named YourServer. aspnet_regsql -C Data Source YourServer Integrated Security True -ssadd When you execute this command a new database is created on your database server named ASPState. The ASPState database contains all the stored procedures used by Session state. However by default Session state information is stored in the TempDB database. When your database server restarts the TempDB database is cleared .