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
exam.
-
Each ASPX page is dynamically converted to a class that derives
its basic functionality from the
System.Web.UI.Page
class.
-
The
Page
directive is used to specify page-
related
attributes that help compilers know how an ASP.NET page is to be
compiled and executed.
-
The
Inherits
attribute of the
Page
directive
specifies the code-behind class for the ASPX page. The
Src
attribute of the
Page
directive specifies the
path
to the
code-behind file. If you are precompiling the code-behind file, you
don't specify the
Src
attribute.
-
To make an HTML control run as a server control, apply the
runat
="server"
attribute to the HTML control.
-
Only some HTML server controls raise events on the server side;
an HTML control can raise either a
ServerClick
event or
ServerChange
event.
-
When the
AutoPostBack
property of the ASP.NET Web
server controls is set to
true
, 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
postback.
-
The preferred way to add client-side event-handling code for Web
server controls is via the the
Attributes
property of the
Web server controls.
-
To set properties on a control at runtime, you use the
control.property
=
value
syntax.
-
To load controls dynamically on a Web form, create the controls
and add them to the
Controls
collection of a container
control, such as
Page
,
Panel
, or
Placeholder
.
-
The
Repeater
and the
DataList
controls use
templates to precisely format data from a collection. The
DataBinder.Eval
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
instantiated
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.
-
The
Response.Redirect()
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
Response.Redirect()
causes an additional round trip to the server.
-
The
Server.Transfer()
method
performs
a server-side
redirection of a page and avoids an extra round trip.
-
The
Server.Execute()
method executes the specified ASPX
file and then returns execution to the calling ASPX page.
-
The file specified as an argument to the
Server.Execute()
or the
Server.Transfer()
method
must be an ASPX file residing on the same Web server, and the
argument should not contain query string data.
-
You should set the
EnableViewStateMac
attribute of the
Page
directive to
false
for the destination page,
in case of calling the page via
Server.Execute()
method or
Server.Transfer()
method with the second argument set to
true
.
-
ASP.NET uses a hidden input control named
__VIEWSTATE
to maintain state for all non-postback controls modified in the
code.
-
You can use the
ViewState
property of the
Page
class to store page-level values. The
ViewState
property
enables you to store structured data as long as the data is
serializable.
-
You can use the
Page.IsPostBack
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
enhance the
user
experience, such as eliminating flash and
persisting
control focus during postback of a Web page for users of
Internet Explorer 5.0 or higher browsers.
-
Session
variables
let you store information across multiple
browser
requests
. 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
database.
-
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
policy.
-
Validation controls provide sophisticated validation on both the
client side and the server side, depending on the validation
settings and the browser's capabilities.
-
The
BaseValidator
class serves as the base class for
all the validation controls. This class provides the basic
implementation of the validation controls.
-
The
RequiredFieldValidator
control can be used to check
whether the input control contains an entry.
-
The
RegularExpressionValidator
control ensures that the
associated input control's value matches a specified regular
expression.
-
The
RangeValidator
control is used to check whether the
input control contains a value in the specified range.
-
The
CompareValidator
control is used to compare the
input server control's value against a data type, a fixed value, or
another input control.
-
The
CustomValidator
control enables you to specify
custom validation code to be executed during validation.
-
The
ValidationSummary
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
GetTextElementEnumerator
method of the
StringInfo
class.
-
SystemException
represents the exceptions thrown by the
CLR, whereas
ApplicationException
represents the
exceptions thrown by the user programs.
-
The
try
block consists of code that can raise an
exception. A
try
block should be immediately followed by
one or more
catch
blocks or a
finally
block.
-
If multiple
catch
blocks are associated with a
try
block, the
catch
blocks should be arranged in
the top-bottom order of specific to general exception types.
-
The
throw
statement is used to raise an exception.
Throwing exceptions is a costly operation. Don't use exceptions
just to manage normal program flow.
-
The
finally
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
customErrors
element in the
web.config
file.
-
You can set a custom error Web page for individual pages in your
application by using the
ErrorPage
attribute of the
Page
directive.
-
You can handle any unhandled error that occurs in a page by
using the page's
Error
event handler.
-
Unhandled exceptions for an entire application can be trapped in
the
Application_Error
event handler in the
global.asax
file.
-
The
Server.CreateObject()
method is used to create
late-bound
COM components. However, not all COM
components
can be
instantiated with
Server.CreateObject()
. 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
<%@Page aspcompat="true"%>
.
-
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
component.
-
You can use
PInvoke
to call functions from unmanaged
libraries. The
DllImport
attribute
tells
the CLR where to
find the implementation of the
extern
method by specifying
the
name
of the library.
-
The
CultureInfo
object represents a culture in the .NET
Framework.
-
The
System.Text.Encoding
class and its subclasses
enable you to convert text from one encoding to another.
-
The .NET Framework provides partial support for mirroring
through the
RightToLeft
property on forms and
controls.
-
You can respond to an event by overriding the
On
method
corresponding to an event. When you use this method, you should be
sure to call the corresponding
On
method for the base
class so that you don't
miss
any of the functionality of the base
class when the event is raised.
-
You can also register events of the
Page
class by
defining event handlers with specific
names
, such as
Page_Init()
,
Page_Load()
, and so on, by setting
the
AutoEventWireup
attribute to
true
in the
Page
directive.
-
The
global.asax
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
WebControl
class.
-
The
DataSet
object represents an entire relational
database in memory. It's
composed
of
DataTable
,
DataRelation
,
DataRow
, and
DataColumn
objects.
-
The
DataView
object provides a filtered row of the data
from a
DataTable
.
-
To persist changes from
DataSet
to the underlying
database, you must call the
Update
method of the
SqlDataAdapter
object.
-
The
UpdateCommand
,
InsertCommand
, and
DeleteCommand
properties of the
SqlDataAdapter
object specifies a
SqlCommand
object to be executed for
updating, inserting and deleting rows respectively.
-
The
FileStream
class treats a file as a raw, typeless
stream of bytes.
-
The
StreamReader
and
StreamWriter
classes are
optimized for textual data, whereas the
BinaryReader
and
BinaryWriter
classes are optimized for structured binary
data.
-
Elements of an XML document can be represented by
XmlNode
objects.
XmlNode
objects are collected
into an
XmlDocument
object, which is the object in the
System.Xml
namespace that represents an entire XML
document.
-
You can also treat an XML document as relational data. To do
this, you can use an
XmlDataDocument
class, which inherits
from
XmlDocument
. The key feature of the
XmlDataDocument
class is that it can be synchronized with
a
DataSet
.
-
The
SqlException
and
SqlError
objects provide
the means to retrieve SQL Server[nd]specific error information.
-
The
System.Web.TraceContext
class can be used to
display trace messages in an application. These messages can be
easily
viewed
by using the trace viewer or at the end of the page
output.
-
Tracing can be enabled at the application level by setting the
trace
element's
enabled
attribute to
true
in the applicationwide
web.config
file. To
enable tracing for an individual page, you set the
trace
attribute to
true
in the
Page
directive.
-
Listeners
are objects that receive trace and debug
output. By default, one listener,
DefaultTraceListener
, is
attached to the
Trace
and Debug
classes
and
displays the messages in the Output window.
-
Debug
and
Trace
objects share the same
listeners collection. Therefore, any listener added to the
Trace.Listeners
collection is also added to the
Debug.Listeners
collection.
-
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.
-
The
Trace
and
Debug
classes from
System.Diagnostics
can be used to display informative
messages in an application when the
DEBUG
and
TRACE
symbols are defined at the time of compilation.
-
By default, both
TRACE
and
DEBUG
symbols are
defined in the Debug Configuration for compilation, and only the
TRACE
symbol is defined for the Release configuration of
compilation.
-
Breakpoints enable you to mark code that signals the debugger to
pause execution when it encounters them.
-
The various tool
windows
, 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
.NET.
-
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
.dll
,
.exe
,
assembly
, and scripts
files.
-
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.
-
The
System.Configuration.Install. Installer
class works
as a base class for all the custom
installers
in the .NET
Framework. The
Install()
method of this class is called
when the application is installed, and the
Uninstall()
method is called when the application is
uninstalled
. The
Commit()
method is executed if the
Install()
method executes successfully; the
Rollback()
method is
executed if the
Install()
method is not executed
successfully.
-
If you add predefined installation components (for example, a
PerformanceCounter
installation component) to the Setup
project, they are added to the
Installers
collection of
the
ProjectInstaller
class.
-
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
cryptographically
strong
name. Public/private key pairs are generated using the Strong Name
tool (
sn.exe
). 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 (
gacutil.exe
), or the Windows
Installer.
-
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
<
codebase
>
and
<probing>
elements of
the
applicable
configuration files.
-
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
module.
-
To save memory and processing time, if your page doesn't depend
on session state, disable it with the
<@% Page
EnableSessionState="false" %>
attribute in the
Page
directive.
-
View state causes additional bytes to travel in each direction
and therefore imposes a speed hit. You can avoid this penalty by
setting the
EnableViewState
property of controls to
false
when you don't need their contents to persist.
-
Using
StringBuilder
can help you achieve noticeable
performance gains in an application using
extensive
string
manipulations.
-
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
tasks
.
-
Use the
SqlClient
managed provider rather than the
generic
OleDb
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
improves
data access
performance significantly.
-
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
using
DataReader
over a
DataSet
.
-
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
ConfigurationSettings
object to
retrieve custom information from a configuration file.
-
The
web.config
file can appear in multiple directories
on an ASP.NET Web application server. Each
web.config
file
applies settings to its own directory and all child directories
below it. The
web.config
files in child directories(can
override or modify settings defined in parent directories..
-
The
machine.config
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
group
membership. Identity impersonation
lets the ASP.NET process act as the authenticated user.
-
OutputCache
directive enables you to cache the output
of pages and user controls in a Web application. When an
OutputCache
directive is applied to an ASPX page, both the
Duration
and
VaryByParam
attributes must be
specified. As opposed to this, in case of user controls, either the
VaryByParam
or
VaryByControl
attribute must be
specified along with the
Duration
attribute.
-
Application data caching
refers to caching
arbitrary data. You can cache any object you want in ASP.NET by
calling the
Add
or
Insert
method of the
Cache
object.