Microsoft ASP.NET Programming with Microsoft Visual Basic .NET Version 2003 Step By Step

Chapter 4 Quick Reference

To

Do this

Example

Store information in the Application collection

Use either the Application object or the Application.Contents collection to add the item to the collection, or use the Application.Add method.

Application (key) = value Application.Contents(key) = value Application.Add(key, value)

Modify information in the Application StaticObjects collection

Add an <Object> tag in Global.asax with the runat="server" attribute and the scope= "application" attribute.

<object runat="server" scope="Application" ></ object>

Store session state in a dedicated server process

Modify the sessionState configuration section of your application’s Web.config file, changing the mode attribute to StateServer and the stateConnectionString attribute to the appropriate IP address and TCP port for the state server being used.

<sessionStatemode="StateServer"stateConnectionString= "tcpip=127.0.0.1:42424"/>

Store session state in a SQL Server database

Modify the sessionState configuration section of your application’s Web.config file, changing the mode attribute to SQLServer and the sqlConnectionString attribute to the appropriate data source name, user ID, and password for the SQL Server being used.

<sessionStatemode="SQLServer"sqlConnectionString= "data source=127.0.0.1;user id=sa;password="/>

Provide support for session state without cookies

Modify the sessionState configuration section of your application’s Web.config file, changing the cookieless attribute to true.

<sessionState cookieless="true"/>

Категории