This Cram Sheet contains the distilled, key facts about
developing and implementing Web applications with Microsoft Visual
C# .NET and Microsoft Visual Studio .NET. Review this information
as the last thing you do before you enter the testing center,
paying special attention to those areas where you feel you need the
most review. You can transfer any of these facts from your head
onto a blank sheet of paper immediately before you begin the
Each ASPX page is dynamically converted to a class that derives
its basic functionality from the
directive is used to specify page-
attributes that help compilers know how an ASP.NET page is to be
compiled and executed.
attribute of the
specifies the code-behind class for the ASPX page. The
attribute of the
directive specifies the
code-behind file. If you are precompiling the code-behind file, you
don't specify the
To make an HTML control run as a server control, apply the
attribute to the HTML control.
Only some HTML server controls raise events on the server side;
an HTML control can raise either a
property of the ASP.NET Web
server controls is set to
, it causes an immediate
postback and allows the Web server to immediately respond to change
events without waiting for a click event to cause a page
The preferred way to add client-side event-handling code for Web
server controls is via the the
property of the
Web server controls.
To set properties on a control at runtime, you use the
To load controls dynamically on a Web form, create the controls
and add them to the
collection of a container
control, such as
templates to precisely format data from a collection. The
method is used to handle casts and
formatting for data in a templated control.
You can import an ActiveX control to a Visual Studio .NET
project by adding it to the Toolbox.
ActiveX controls are
on the client, not the server.
Any event handlers for the control must be written in a scripting
language and will also execute on the client. ActiveX controls
impose a performance penalty and have other drawbacks.
method can be used to connect
to any specified URL. The specified URL can point to any resource
and contain query strings. The use of
causes an additional round trip to the server.
redirection of a page and avoids an extra round trip.
method executes the specified ASPX
file and then returns execution to the calling ASPX page.
The file specified as an argument to the
must be an ASPX file residing on the same Web server, and the
argument should not contain query string data.
You should set the
attribute of the
for the destination page,
in case of calling the page via
method with the second argument set to
ASP.NET uses a hidden input control named
to maintain state for all non-postback controls modified in the
You can use the
property of the
class to store page-level values. The
enables you to store structured data as long as the data is
You can use the
property to determine
whether a page is being loaded for the first time or in response to
a postback operation.
ASP.NET has a feature called smart navigation that can greatly
experience, such as eliminating flash and
control focus during postback of a Web page for users of
Internet Explorer 5.0 or higher browsers.
let you store information across multiple
. The default storage location for session state is
in-process memory in the ASP.NET process itself. The session state
can be scaled to support multiple Web servers in a Web farm by
storing the state in a separate process or in a SQL Server
ASP.NET provides two ways to store global data
Application state and application data cache. The application data
cache provides advanced features such as a cache expiration
Validation controls provide sophisticated validation on both the
client side and the server side, depending on the validation
settings and the browser's capabilities.
class serves as the base class for
all the validation controls. This class provides the basic
implementation of the validation controls.
control can be used to check
whether the input control contains an entry.
control ensures that the
associated input control's value matches a specified regular
control is used to check whether the
input control contains a value in the specified range.
control is used to compare the
input server control's value against a data type, a fixed value, or
another input control.
control enables you to specify
custom validation code to be executed during validation.
control is used to display a
summary of all the validation errors of a Web page.
To iterate through the elements of a string in a world-ready
application, you should use the
method of the
represents the exceptions thrown by the
exceptions thrown by the user programs.
block consists of code that can raise an
block should be immediately followed by
one or more
blocks or a
blocks are associated with a
blocks should be arranged in
the top-bottom order of specific to general exception types.
statement is used to raise an exception.
Throwing exceptions is a costly operation. Don't use exceptions
just to manage normal program flow.
block is used to enclose the code that
needs to be run regardless of whether the exception is raised.
Custom error pages can be configured by using the
element in the
You can set a custom error Web page for individual pages in your
application by using the
attribute of the
You can handle any unhandled error that occurs in a page by
using the page's
Unhandled exceptions for an entire application can be trapped in
event handler in the
method is used to create
COM components. However, not all COM
. In particular,
components that use the STA threading model will not function
properly in ASP.NET pages unless you add a compatability directive
to the page, such as
Using COM or COM+ components from .NET-managed code requires the
creation of a runtime callable wrapper (RCW). RCWs impose a
performance penalty on COM code.
You can create an RCW for a COM component by either using the
Type Library Importer or directly referencing the COM component
from your .NET code.
To use COM components you did not create, you should obtain a
primary interop assembly (PIA) from the creator of the
You can use
to call functions from unmanaged
the CLR where to
find the implementation of the
method by specifying
of the library.
object represents a culture in the .NET
class and its subclasses
enable you to convert text from one encoding to another.
The .NET Framework provides partial support for mirroring
property on forms and
You can respond to an event by overriding the
corresponding to an event. When you use this method, you should be
sure to call the corresponding
method for the base
class so that you don't
any of the functionality of the base
class when the event is raised.
You can also register events of the
defining event handlers with specific
, such as
, and so on, by setting
file is the appropriate place to handle
global events that are not specific to a Web form but rather apply
to an application as a whole.
Web user controls let you encapsulate common blocks of user
interface functionality for reuse. They must be contained within
the project in which they are used.
Web custom controls are compiled components that offer support
for almost all the features of the server controls that ship with
Visual Studio .NET.
You can create a Web custom control by combining existing
controls, by deriving it from an existing control, or by inheriting
it directly from the
object represents an entire relational
database in memory. It's
object provides a filtered row of the data
To persist changes from
to the underlying
database, you must call the
method of the
properties of the
object specifies a
object to be executed for
updating, inserting and deleting rows respectively.
class treats a file as a raw, typeless
stream of bytes.
optimized for textual data, whereas the
classes are optimized for structured binary
Elements of an XML document can be represented by
objects are collected
object, which is the object in the
namespace that represents an entire XML
You can also treat an XML document as relational data. To do
this, you can use an
class, which inherits
. The key feature of the
class is that it can be synchronized with
the means to retrieve SQL Server[nd]specific error information.
class can be used to
display trace messages in an application. These messages can be
by using the trace viewer or at the end of the page
Tracing can be enabled at the application level by setting the
in the applicationwide
enable tracing for an individual page, you set the
are objects that receive trace and debug
output. By default, one listener,
attached to the
displays the messages in the Output window.
objects share the same
listeners collection. Therefore, any listener added to the
collection is also added to the
Trace switches enable you to change the type of messages traced
by a program depending on the value stored in the XML configuration
file. You don't need to recompile the application for this change
to take effect.
can be used to display informative
messages in an application when the
symbols are defined at the time of compilation.
By default, both
defined in the Debug Configuration for compilation, and only the
symbol is defined for the Release configuration of
Breakpoints enable you to mark code that signals the debugger to
pause execution when it encounters them.
The various tool
, such as Locals, Autos, Watch, and Call
Stack, can be of great help in tracking the execution path and the
status of variables when debugging an application in Visual Studio
Use the Exceptions dialog box to customize how the exceptions
are thrown in your program.
You can attach a debugger to a running process (local or remote)
with the help of the Processes dialog box.
The Custom Actions Editor enables you to add custom actions to
be performed during the installation process. It allows you to run
, and scripts
The Launch Conditions editor enables you to set conditions to be
evaluated when the installation begins on the target machine. If
the conditions are not met, the installation stops.
as a base class for all the custom
in the .NET
method of this class is called
when the application is installed, and the
method is called when the application is
method is executed if the
method executes successfully; the
executed if the
method is not executed
If you add predefined installation components (for example, a
installation component) to the Setup
project, they are added to the
Shared assemblies are used by multiple applications on a
machine. They are placed in the GAC and enjoy special priviliges,
such as file security (because they are placed in the System
folder), shared location, and side-by-side versioning.
A shared assembly must be assigned a
name. Public/private key pairs are generated using the Strong Name
). The pairs can then be used to digitally
sign an assembly.
A shared assembly can be added to the GAC by using Windows
Explorer, the .NET Framework Configuration tool, the Global
Assembly Cache Tool (
), or the Windows
The CLR first searches the GAC to locate assemblies before
looking in the files and folders where the application is
installed. Thus, shared assemblies placed in the GAC are more
efficient because the CLR does not look in the
Delay signing enables a shared assembly to be placed in the GAC
by just signing the assembly with the public key. This allows the
assembly to be signed with a private key at a later stage when the
development process is complete and the component or assembly is
ready to be deployed.
Merge modules enable you to create reusable components that help
in deploying shared components. The merge modules cannot be
directly installed; they need to be merged with installer programs
of applications that use the component packed into the merge
To save memory and processing time, if your page doesn't depend
on session state, disable it with the
attribute in the
View state causes additional bytes to travel in each direction
and therefore imposes a speed hit. You can avoid this penalty by
property of controls to
when you don't need their contents to persist.
can help you achieve noticeable
performance gains in an application using
Reduce the number of calls between the managed and unmanaged
code, possibly by doing more work in each call rather than making
frequent calls for doing small
managed provider rather than the
managed provider to retrieve data from the
SQL Server database.
SQL Server stored procedures are highly optimized for
server-side data access, and their use usually
Run SQL Server's Profiler and Index Tuning Wizard to avoid any
bottlenecks because of indexing. Also, use the SQL Server Query
Analyzer to optimize a query's performance.
If you are reading a table sequentially, give preference to
The SQL Server .NET Data provider provides connection pooling to
improve performance when connecting to a database. Use the same
connection strings to connect to the database to utilize the
performance gains provided by connection pooling.
You can use the
retrieve custom information from a configuration file.
file can appear in multiple directories
on an ASP.NET Web application server. Each
applies settings to its own directory and all child directories
below it. The
files in child directories(can
override or modify settings defined in parent directories..
file contains settings that control
the operation of .NET on the entire computer. For example, compiler
settings for the .NET Framework are stored in this file.
Role-based security enables you to authorize access to resources
based on user identity or
membership. Identity impersonation
lets the ASP.NET process act as the authenticated user.
directive enables you to cache the output
of pages and user controls in a Web application. When an
directive is applied to an ASPX page, both the
attributes must be
specified. As opposed to this, in case of user controls, either the
attribute must be
specified along with the
Application data caching
refers to caching
arbitrary data. You can cache any object you want in ASP.NET by
method of the