Академический Документы
Профессиональный Документы
Культура Документы
Knowledge Byte
• In this section, you will learn to:
Policy-Level Description
Best Practices
Optimizing State Management
• The best practices that should be followed while designing state management:
• The Application object that stores the application-level information
should be replaced with static properties.
• The session state should be disabled in all the pages that do not require
per-user session state. You can set the value of the
EnableSessionState attribute of the page directive to false to disable
the per-user session for a page. The value of EnableSessionState
should be set to read-only on the pages that only access session
variables but do not modify or create them.
• The Viewstate should be disabled at the application level. Set the value
of the enableViewState attribute of the <page> tag to false. Enable
the Viewstate on pages where it is required. Set the value of the
EnableViewState attribute of the page directive to true to enable the
Viewstate.
• Minimize the number of objects that are stored in the Viewstate.
©NIIT Collaborate Lesson 4C / Slide 14 of 18
Collaborate
FAQs
• Can I use the in-process state management option over a Web farm?
• Yes, as different servers furnish requests from a single user, it impossible
to mange the session state under normal settings. You can configure the
Application Center to force one sever to furnish all the requests from a
specific client. This feature is called sticky IP.
• Can I change the default port used while using the stateserver option for
session state management?
• Yes, you can change the default port by editing the value stored in the
HKLM\SYSTEM\CurrentControlSet\Services\aspnet_state key in
the system registry.
FAQs (Contd.)
• How can I configure my SQL Server to implement session management with
SQL Server?
• To use SQL Server for session state management, you must create the
ASPState database on the SQL Server. You can create the ASPState
database by running InstallState.sql script. This script can be located at
the following location:
%WinDi%r\Microsoft.Net\Framework\Version
Where, Version refers to the version of .Net Framework installed on your
computer.
• My ASP.NET page has a datagrid that is bound to a large database. Can I apply
caching to improve the performance of this page?
• Yes, the best strategy is to implement fragment caching. You should first
create a user control that will include this DataGrid control and then apply
the fragment cache on this user control.
Challenges
• Your company, BlueMoon Solution Inc., is developing an Online Book Store
application for NewTechBookStore. As a member of the development team,
you are aware of the application requirement. One of the modules you are
working on uses two tables, BookCategories and BookItems. The module
only displays the data in the BookCategories table and does not perform any
modification. The BookItems table is updated in this module. You want to
optimize this module to improve the response time of this page. What
should you do?
a. Store the BookItems table in a session variable and cache the
BookCategories table. FETCH
b. Store the BookCategories table in a session variable and cache the
BookItems
c. Store both the tables in two separate session variables.
d. Cache both the tables.
Solutions
1. a. Store the BookItems table in a session variable and cache the
BookCategories table.