06 ASP - Net Session08
06 ASP - Net Session08
06 ASP - Net Session08
NET
Objectives
Problem Statement:
You are a developer in the Adventure Works organization, a
fictitious bicycle manufacturer. You have been asked to assist
in the development of the Business-to-Consumer (B2C) Web
application and a related Business-to-Employee (B2E) extranet
portal.
Decisions on the design of the application have already been
made. As part of the first phase of the B2C development, you
have been asked to configure the behavior of Web server
controls by manipulating their ViewState properties. You have
also been asked to add a site-counter to the site, which will
display user numbers and store data in the Application and
Session objects.
You will also specify how the Web application stores and
manages session state data. Finally, you have been asked to
implement caching by using the Cache object to store bike
review data.
Solution:
To solve this problem, you need to perform the following tasks:
1. Configuring ViewState Properties for Web Server Controls
a. Open the Adventure Works Web site.
b. Set the EnableViewState property of Web server controls.
c. Test the ViewState after a Web page is submitted.
d. Disable ViewState for the BikeReview.aspx page.
e. Work with the MaxPageStateFieldLength property to divide the
ViewState data into chunks.
2. Storing and Retrieving Application and Session State
a. Initialize information in the Application object.
b. Write code to increment the UserCount value when a new user session
begins.
c. Store Data in the Session object.
d. Retrieve Application and Session state data and display it on the Web
page.
Database=AdventureWorks;
Integrated Security=SSPI;Persist Security
Info=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
Providers:
A provider is a class that can communicate with a specific type
of database or data store.
ASP.NET provides a number of providers that can
communicate with a wide variety of data stores.
The providers include, the .NET framework data provider for:
SQL server in the System.Data.SqlClient namespace
OLE DB in the System.Data.OleDb namespace
ODBC in the System.Data.Odbc namespace
Oracle in the System.Data.OracleClient namespace
Caching:
The SqlDataSource control can cache data that it has
retrieved.
Caching can be enabled by setting EnableCaching to
true.
CacheDuration property can be set to specify the number
of seconds to cache data.
Cache dependency feature of SQL Server can also be used
by SqlDataSource control.
By using cache dependency, retrieval of data can be
minimized.
<tr>
<td>
<asp:Button ID="btnInsert" runat="server"
CommandName="Insert" Text="Save"/>
</td>
<td>
<asp:Button ID="btnCancel" runat="server"
CommandName="Cancel" Text="Cancel"/>
</td>
</tr>
</table>
</InsertItemTemplate>