Webapps (mcad)

48

description

C# web apps mcad

Transcript of Webapps (mcad)

Page 1: Webapps (mcad)
Page 2: Webapps (mcad)

C# .NET Web Apps (70-315)

Table of Contents Creating User Services ................................................................................................................................................... 4

Create ASP.NET pages. ............................................................................................................................................... 4 Add and set directives on ASP.NET pages. ............................................................................................................. 4 Separate user interface resources from business logic............................................................................................ 6

Add Web server controls, HTML server controls, user controls, and HTML code to ASP.NET pages. ....................... 6 Set properties on controls. ........................................................................................................................................ 7 Load controls dynamically. ....................................................................................................................................... 8 Apply templates. ....................................................................................................................................................... 8 Set styles on ASP.NET pages by using cascading style sheets. ............................................................................. 9

Implement navigation for the user interface................................................................................................................ 10 Manage the view state. ........................................................................................................................................... 10 Manage data during postback events..................................................................................................................... 11 Use session state to manage data across pages................................................................................................... 11

Validate user input. ..................................................................................................................................................... 11 Implement error handling in the user interface. .......................................................................................................... 13

Configure custom error pages. ............................................................................................................................... 13 Implement Global.asax, application, page-level, and page event error handling................................................... 14

Display and update data. ............................................................................................................................................ 14 Bind data to the user interface................................................................................................................................ 15 Transform and filter data......................................................................................................................................... 16 Use controls to display data.................................................................................................................................... 16

Instantiate and invoke a Web service or component. ................................................................................................. 16 Instantiate and invoke a Web service. .................................................................................................................... 16 Instantiate and invoke a COM or COM+ component.............................................................................................. 17 Instantiate and invoke a .NET component.............................................................................................................. 19 Call native functions by using platform invoke........................................................................................................ 20

Implement globalization. ............................................................................................................................................. 20 Implement localizability for the user interface......................................................................................................... 21 Convert existing encodings..................................................................................................................................... 21 Implement right-to-left and left-to-right mirroring. ................................................................................................... 22 Prepare culture-specific formatting. ........................................................................................................................ 22

Handle events. ............................................................................................................................................................ 23 Create event handlers. ........................................................................................................................................... 24 Raise events. .......................................................................................................................................................... 24

Use and edit intrinsic objects. Intrinsic objects include response, request, session, server, and application. ........... 25

Page 3: Webapps (mcad)

C# .NET Web Apps (70-315)

Creating and Managing Components and .NET Assemblies.................................................................................... 26 Create and modify a .NET assembly. ......................................................................................................................... 26

Create and implement satellite assemblies. ........................................................................................................... 26 Create resource-only assemblies. .......................................................................................................................... 26

Create custom controls and user controls. ................................................................................................................. 27 Consuming and Manipulating Data ............................................................................................................................. 28

Access and manipulate data from a Microsoft SQL Server™ database by creating and using ad hoc queries and stored procedures. ...................................................................................................................................................... 28 Access and manipulate data from a data store. Data stores include relational databases, XML documents, and flat files. Methods include XML techniques and ADO .NET.............................................................................................. 28 Handle data errors. ..................................................................................................................................................... 32

Testing and Debugging................................................................................................................................................. 33 Create a unit test plan. ................................................................................................................................................ 33 Implement tracing........................................................................................................................................................ 33

Add trace listeners and trace switches to an application........................................................................................ 34 Display trace output. ............................................................................................................................................... 35

Debug, rework, and resolve defects in code............................................................................................................... 36 Configure the debugging environment.................................................................................................................... 36 Create and apply debugging code to components, pages, and applications. ........................................................ 37 Provide multicultural test data to components and applications............................................................................. 37 Execute tests. ......................................................................................................................................................... 38 Resolve errors and rework code............................................................................................................................. 38

Deploying a Web Application....................................................................................................................................... 38 Plan the deployment of a Web application.................................................................................................................. 38 Create a setup program that installs a Web application and allows for the application to be uninstalled. ................. 38 Deploy a Web application. .......................................................................................................................................... 39 Add assemblies to the Global Assembly Cache. ........................................................................................................ 40

Maintaining and Supporting a Web Application......................................................................................................... 41 Optimize the performance of a Web application. ........................................................................................................ 41 Diagnose and resolve errors and issues..................................................................................................................... 42

Configuring and Securing a Web Application ............................................................................................................ 42 Configure a Web application. ...................................................................................................................................... 42

Modify the Web.config file....................................................................................................................................... 42 Modify the Machine.config file. ............................................................................................................................... 42 Add and modify application settings. ...................................................................................................................... 42

Configure security for a Web application. ................................................................................................................... 43 Select and configure authentication type. Authentication types include Windows® Authentication, None, forms-based, Microsoft Passport, Internet Information Services (IIS) authentication, and custom authentication. ......... 43

Page 4: Webapps (mcad)

C# .NET Web Apps (70-315)

Configure authorization. Authorization methods include file-based methods and URL-based methods.................... 43 Configure role-based authorization......................................................................................................................... 43 Implement impersonation. ...................................................................................................................................... 44

Configure and implement caching. Caching types include output, fragment, and data.............................................. 44 Use a cache object, cache directives. .................................................................................................................... 44

Configure and implement session state in various topologies such as a Web garden and a Web farm.................... 45 Use session state within a process......................................................................................................................... 45 Use session state with session state service. ........................................................................................................ 45 Use session state with Microsoft SQL Server. ....................................................................................................... 46

Install and configure server services........................................................................................................................... 46 Install and configure a Web server. ........................................................................................................................ 46 Install and configure Microsoft FrontPage® Server Extensions. ............................................................................ 47

Page 5: Webapps (mcad)

C# .NET Web Apps (70-315)

Creating User Services Create ASP.NET pages. To start creating a new ASP.NET Web Application written in C#, you must select the New Project button or menu command. When the New Project Wizard appears, select Visual C# Projects and then ASP.NET Web Applications.

It’s then possible to specify the location of the project that can be on the local computer (http://localhost/) or on another machine with IIS installed.

Add and set directives on ASP.NET pages. Directives are used to specify settings of an ASP.NET page (.aspx) or control (.ascx). Directives must be declared within <%@ and %> (open and close directive tags).

There are several directives:

@ Page (only in .aspx files) Defines page-specific attributes like Language, CodeBehind, etc.

@ Control (only in .ascx files) Defines control-specific attributes.

@ Import Imports a namespace.

@ Implements Declares that a specific interface is implemented.

Page 6: Webapps (mcad)

C# .NET Web Apps (70-315)

@ Register Creates aliases.

@ Assembly Links an assembly.

@ OutputCache Controls the output caching.

@ Reference Links a page or a user control.

When the directive name is missing, Page is assumed for an .aspx file and Control is assumed for an .ascx file.

Here is an example of a Page directive:

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="Cramsession70_315.WebForm1" %>

Page 7: Webapps (mcad)

C# .NET Web Apps (70-315)

Separate user interface resources from business logic. Code-behind is used to separate directives and page layout from the Visual C# code.

The HTML tags and ASP.NET directives are saved in .aspx files, and the code is saved in .aspx.cs files.

The link between the two set of files is maintained in the Page directive (like in the previous paragraph).

When the user loads an .aspx page, the code-behind is loaded and is compiled with the page. This allows having two different groups of developers that work on the project: one group designing the pages and the other group writing the code.

By default Visual Studio.NET generates a code-behind version of every ASP.NET page.

Add Web server controls, HTML server controls, user controls, and HTML code to ASP.NET pages. To add HTML code to an ASP.NET page, simply select the HTML at the bottom of the .aspx page.

To add controls to a page, simply select the Toolbox and drag the desired control to the design view of a page.

To the right is an example of a Toolbox.

HTML server controls are typical HTML elements that have the runat attribute set to server. This setting enables the persistence of the selections made by the user and other interesting behaviors (that are different for each control). HTML server controls maintain the naming used in normal HTML tags and are typically used to migrate existing ASP or HTML pages. To convert an HTML control in an HTML server control simply add the attribute in the HTML view or

Page 8: Webapps (mcad)

C# .NET Web Apps (70-315)

right-click the control in design view and select Run as Server control.

Web server controls (also called ASP.NET server controls) are similar to HTML server controls (they also require the runat=”server” attribute), but they have different names and different properties (that are coherent between different controls). Web server controls are more than HTML controls because there are complex controls like a calendar, the AdRotator, DataGrid, and so on.

Another difference is that Web server controls support a greater number of events.

Set properties on controls. To set properties on controls (but also on web pages and other elements) use the Properties Window:

By selecting the icon, you can also look at events (only if the control supports them).

Page 9: Webapps (mcad)

C# .NET Web Apps (70-315)

It’s possible to set default properties of a control by editing the control in the HTML view. It’s also possible to change or to read properties of a control in C# code simply by using the dot notation (control.property).

Load controls dynamically. To dynamically create controls and to add them on a page a container control must be present (for example, a table can be used as a container for dynamically generated rows). Placeholder or Panel Web server controls can be used as containers when there are no container controls.

Here is an example of a new dynamic label added to a container called Container1:

Label myLabel = new Label();

myLabel.Text = "Cramsession";

Container1.Controls.Add(myLabel);

Apply templates. Templates are used to change how some of the Web server controls are rendered in HTML. Templates consist of HTML and/or embedded server controls that are rendered in place of the default HTML for the control.

DataList and Repeater controls require a template to display output (their default templates are empty).

A control can have multiple templates, one for every part of the control. Here is a list of controls that supports templates and their templates:

Repeater HeaderTemplate, FooterTemplate, ItemTemplate, AlternatingItemTemplate, SeparatorTemplate

DataList HeaderTemplate, FooterTemplate, ItemTemplate, AlternatingItemTemplate, SeparatorTemplate, SelectedItemTemplate, EditItemTemplate

DataGrid HeaderTemplate, FooterTemplate, ItemTemplate (column), EditItemTemplate (column), Pager

Here is an example on how to apply, in the HTML, view some templates to a DataList:

<asp:datalist ID="DataList1" runat="server">

<HeaderTemplate>

Page 10: Webapps (mcad)

C# .NET Web Apps (70-315)

</HeaderTemplate>

<ItemTemplate>

</ItemTemplate>

</asp:datalist>

Set styles on ASP.NET pages by using cascading style sheets. There are many options to use CSS on an ASP.NET page. The first options are like any other HTML page with CSS:

Using <STYLE></STYLE> tags in the HEAD section of the HTML page

Importing an external CSS using <LINK REL="stylesheet" TYPE="text/css" HREF="filename.css"> in the HEAD section of the HTML page

It’s also possible to set properties like ForeColor, BackColor, Font (Bold, Italic and so on) on controls and have these properties rendered as a STYLE attribute if the user browser supports it, or rendered in other ways (like, for example, a FONT statement) if doesn’t support style sheets.

Composite controls can have multiple styles (for example the Calendar control can have DayStyle, SelectedDayStyle, WeekEndDayStyle, etc., each used on different part of the control).

It’s also possible to set the CSSClass property of a control if classes were defined in the CSS file.

The CSSStyle property is available on some controls allowing you to set style attributes. But, if explicit properties are also declared (like ForeColor), they take precedence.

Page 11: Webapps (mcad)

C# .NET Web Apps (70-315)

Implement navigation for the user interface. When a Web Form is sent to the browser it’s also destroyed on the server, so it’s not directly possible to retain the value of the used variables.

Here are some ways to solve this problem (MSDN: Introduction to Web Forms State Management):

Query strings – This information is passed between requests and responses as part of the Web address. Since they are visible to the user, they should not contain secure information such as passwords.

Cookies – Are used to store small amounts of information on a client. Clients might refuse cookies, so don’t rely on them.

View State - Items are stored as hidden fields on the page.

Session variables - Items that are local to the current session (single user) can be stored in Session variables.

Application variables – Are used to store items that must be available to all users of the application.

Manage the view state. The ViewState property (available for every control on a page and for the page itself) is used to store the value of each control that will be restored on every posting of the page between the client and the server.

It’s also possible to store and retrieve custom information, in the form of strings.

Use ViewState["xxx"]= “string value” to write to a particular item in the ViewState collection. Remember that complex objects must be serialized in the form of strings.

The value red from the ViewState collection is an object that must be converted to the desired type.

The ViewState collection is stored in a hidden form field on the HTML page, and requires one <form runat=”server”> to run.

Page 12: Webapps (mcad)

C# .NET Web Apps (70-315)

Manage data during postback events. When a page is loaded for the first time, it must be filled with all the default values.

When a form redirects the user on the same page, the page must retain the user selected values.

To distinguish between these cases, the IsPostBack property of the page can be used. If it’s true, the page was posted back from the browser, and so it must not be cleared with the default values.

Use session state to manage data across pages. Session variables can be used to maintain state information across different request from the client browser on a per user basis.

When a browser requests a page and a session state is enabled, the server recognizes that the client’s requesting its first page. It then raises the Session_OnStart event and creates a session context.

Every thing that is stored in session variables can be read only by pages requested from the same browser.

If the browser doesn’t requires a page before the timeout period, or the session is explicitly closed, the Session_OnEnd event is raised and the session is closed.

Validate user input. MSDN – Web Forms Validation

Validation controls are used to validate user input in Web Forms. They allow validating on both the server and client side (on IE 4.0 or later).

There are several validation controls:

RequiredFieldValidator The Field is required.

CompareValidator The value of the Field is compared against a constant value, or against a property value of another control. Supported operators are: less than, equal, greater than, and so on.

RangeValidator The value must be between specified lower and upper boundaries.

RegularExpressionValidator The value of the Field must match the given regular expression.

CustomValidator The value must comply with user’s defined rules.

Simply add a validation control from the Toolbox to the Web Form (typically next to the control that must be validated).

Page 13: Webapps (mcad)

C# .NET Web Apps (70-315)

Every validation control has some common properties like:

ControlToValidate – The control that is validated

Text – This text is displayed near the control (typically a star “*”)

ErrorMessage – This text can be displayed in a ValidationSummary control

There are other properties like ValidationExpression, ValueToCompare, Operator, etc. that are specific to each validation control type.

Multiple validation rules can be applied to a single control. Validation controls are always combined using a logical AND.

It’s possible to display the error information near the control or in a specific place on a page. The ValidationSummary control can be used to display information about every error in the page in one place. Typically the control is put on the top or on the bottom of the page, or where there is enough space for some lines.

It’s possible to programmatically see if a condition is matched by checking the IsValid property of a validation control, for example, in the Page Load event.

It’s also possible to force a validation by calling the Validate method on a validation control.

Page 14: Webapps (mcad)

C# .NET Web Apps (70-315)

Implement error handling in the user interface. In traditional languages, errors are generally reported by every single code statement as error codes, and must be handled with if statements. This approach tends to make the code unreadable.

C#, like many other object-oriented languages allows, handling errors using exceptions.

Put the code inside a try…catch…finally block:

try {

code that can generate an exception

}

catch ( exceptionClass excObject )

{

code that handles the exception

}

finally

{

code that is always executed (clean-up code)

}

There can be more than one catch block, from the most detailed exception to the most general one.

Catch and finally blocks are optional, but at least one of them is needed.

Exceptions are objects derived from System.Exception. It’s possible to define custom

exceptions (that derive from System.ApplicationException) or to use system exceptions (that derive from System.SystemException).

If errors are not trapped, they are handled by the ASP.NET runtime.

Configure custom error pages. The Web.config file can be used to configure the pages used to display custom errors.

The <customErrors> tag can contain a defaultredirect attribute that specifies the page that is called when there is a generic error. The mode attribute can be set to ‘On’, forcing the redirection to the error page, or to ‘Off’, forcing a detailed description of the error by the ASP.NET runtime. The ‘RemoteOnly’ setting works like On for remote clients and like Off for the users on the local server.

Page 15: Webapps (mcad)

C# .NET Web Apps (70-315)

A <customErrors> tag can contain more <error> tags that must specify the statuscode of the error (in numeric format; i.e., 404 for File Not Found) and the redirect page.

Here is an example:

<customErrors defaultredirect="/error/generalError.aspx" mode="on">

<error statuscode="404" redirect="/error/filenotfound.aspx" />

</customErrors>

While it is possible to configure the same information in IIS this requires editing and deploying the IIS metabase, whereas using the web.config method only requires the distribution of a text file.

This error handling technique works only for ASP.NET files (.aspx, .ascx, .asmx, etc…), while IIS error handling works for every file type (.htm, .gif, .jpg, etc.)

Implement Global.asax, application, page-level, and page event error handling. The Application_Error event handler is called when no appropriate error handler is set at page level. Application_Error can be found in the Global.asax file, and is called before checking the Web.config.

The <%@Page ErrorPage=”errorPage.aspx”%> directive is used to redirect to an error page on a page by page basis. This is invoked before the Application_Error and Web.config

The Page_Error event handler is called when there is an error on a page, and is called before all the other methods.

Use the Page_Error event handler if you want to trap the error in the page that has generated it. Use the ErrorPage directive if you want to specify an error page for a specific page. Use the Application_Error if you want to handle errors at application level, and use the Web.config gile if you want to handle errors in a declarative way, without writing the error handler.

Use Server.GetLastError to obtain error information.

Use Server.ClearError to prevent the error from flowing from Page_Error to the ErrorPage directive, to the Application_Error, and then to the Web.config.

Display and update data. In ASP.NET Web Forms, you can read data with ADO.NET from a data source and produce HTML by writing code (like in any other environment). You can also bind data directly to Web Forms Server controls, not only from traditional data sources (like DataSets), but also to almost any structure that contains data like arrays, collections, properties or other controls.

Page 16: Webapps (mcad)

C# .NET Web Apps (70-315)

Bind data to the user interface. You can bind single-value controls in the HTML view using a data-binding expression <%# source %>.

For example, you bind the datafield field of the first record of the dataView to a TextBox with the following code:

<asp:TextBox id=’TextBox1’ runat=’server’ Text=’<%# dataView[0][“datafield”] %>’>

</asp:TextBox>

You can also use the visual designer and select the DataBindings property. From the DataBindings dialog box, bind every property of the control to a data source.

When there are list controls on the page (Repeater, DataList, DataGrid, CheckBoxList, and RadioButtonList), the data binding for those controls must be specified as a whole using special data-binding properties:

The DataSource property defines the data source of the control.

The DataMember property is used to define the table of the dataset that is mapped.

The DataKeyField property is used on DataList or DataGrid and is typically associated to the primary key of the table.

The DataTextField is used with ListBox, DropDownList, CheckBoxList, RadioButtonList, or HtmlSelect controls to determine which column to bind.

The DataValueField optional property is related to the previous property and defines which column must the value of the selected item is taken from.

Page 17: Webapps (mcad)

C# .NET Web Apps (70-315)

Transform and filter data There are situations where data retrieved from a data source does not match with the data type of the destination control.

Two events, Format and Parse, allow transforming the data before sending the data to the control and vice versa.

These events also allow creating custom formats for displaying data.

The Format event is fired when the property is bound, when the Position changes, or when the data is changed (sorted or filtered).

The Parse event is fired after the Validated event, when the Position changes, or when the EndCurrentEdit method is called.

To filter data in a DataSet, use the Select statement or a DataView (that is a View on the DataSet).

Use controls to display data. To actually do the data binding, call the DataBind method of the page or of the control (this is valid in all the previous cases).

The DataBind method is typically called only when the page is first loaded, and not on every post back, in order to avoid overwriting the value of the control selected or edited by the user.

Instantiate and invoke a Web service or component. Instantiate and invoke a Web service. To use an XML Web Service a proxy class must be created by using the Add Web Reference command in the Project menu of the Visual Studio.NET or by using the WSDL.EXE command from the command line.

Using the Add Web Reference displays a form where it is possible to find Web Services on the UDDI Registry, or by using the WSDL description of the service directly.

Page 18: Webapps (mcad)

C# .NET Web Apps (70-315)

The generated proxy can be instantiated like any other class.

mssoapsampleserver.Calc sampleCalculator = new

mssoapsampleserver.Calc();

double result = sampleCalculator.Add(10,20);

The namespace, the name of the class and the name of the methods are taken from the WSDL description of the XML Web Service.

There are a set of properties and methods that are always generated. These allow you to control the Web Service client. For example, the Url property allows you to change the URL of the Web Service.

Instantiate and invoke a COM or COM+ component. From the .NET managed code, call COM and COM+ components using the Runtime Callable Wrapper (RCW).

The RCW is created when a .NET Client loads a COM component. There is one RCW for each COM component, ensuring that they represent a single object identity.

Page 19: Webapps (mcad)

C# .NET Web Apps (70-315)

When the RCW is created, it reads the COM type library of the component and exposes every interface and every method of the component.

The RCW is responsible for keeping the COM object alive as long as the RCW is not garbage collected.

When a method is called on the RCW, it converts the parameters between .NET and COM types and vice-versa.

Then the RCW converts the HRESULT errors (if there are any) from the COM component in .NET exceptions, and converts results into .NET types.

To generate the RCW, use the TLBIMP.EXE command-line utility or the Visual Studio.NET Add Reference command in the Project menu (see image, next page).

Page 20: Webapps (mcad)

C# .NET Web Apps (70-315)

Instantiate and invoke a .NET component. A .NET component is a class that implements the System.ComponentModel.IComponent interface (directly or by deriving it from another class that implements that interface).

IComponent interface extends the System.IDisposable interface, which has a method called Dispose that is called to release external resources explicitly.

When a component is created (via the new operator), the component is created in the garbage collected heap.

When there are no more references to the component, the garbage collector marks the component and, when the memory is needed, the finalizer is called.

If the component holds references to some expensive resources, these resources are taken until the component is finalized. The Dispose method can be explicitly called to release those resources and free them.

A .NET component can be included by using the Add Reference menu of the Visual Studio.NET or by customizing the Toolbox. Every .NET component has the RAD support built in the Framework, without requiring other code from the developer.

Page 21: Webapps (mcad)

C# .NET Web Apps (70-315)

Call native functions by using platform invoke. To call functions in unmanaged code use the DllImport attribute.

[DllImport("KERNEL32.DLL", EntryPoint="MoveFileW",

SetLastError=true,

CharSet=CharSet.Unicode, ExactSpelling=true,

CallingConvention=CallingConvention.StdCall)]

public static extern bool MoveFile(String src, String dst);

DllImport must be placed on every method declaration, and has five parameters:

“name and location” of the DLL that contains the function that is called

EntryPoint – Is the name of the entry point in the DLL

CharSet – Is the character set used in the entry point. The default value is CharSet.Auto

ExactSpelling – Indicates if the EntryPoint must exactly match the spelling of the entry point. The default value is False

CallingConvention – Indicates the calling convention. The default value is CallingConvention.Winapi

DllImport is part of the namespace System.Runtime.InteropServices and it must be declared with the using keyword, or must be added to the name of the attribute.

Implement globalization. The .NET Framework supports multiple cultures and languages. The CultureInfo class contains culture specific information like:

Language

Country/region

Page 22: Webapps (mcad)

C# .NET Web Apps (70-315)

Calendar

Etc.

Each culture has a unique name formed by two lowercase letters called culture code (the language; i.e., en, it, fr, de, etc.) and optionally two uppercase letters that specify the country or the region (i.e., IT, CH, etc.)

Implement localizability for the user interface. GOTDOTNET – Localizing ASP.NET Applications

The simplest method to localize a Web user interface is the “copy and translate” method.

Simply prepare several versions of the same page, each with localized content and with the <%@Page Culture="..." %> directive.

The Culture directive allows you to change the default culture used by the page, so it’s possible to format a date using <%=DateTime.Now.ToString("f", null)%> in the localized format.

The second way is to use controls that support localization of the content. It’s always better to specify the UICulture Page directive, with the same value of the Culture directive, because the UICulture is often used by controls to determine the localization.

The third way is to put localization data in resource only assemblies (see later), so when there is the need of a new language, simply add a new dll to the web application.

The last way is to put localization data in a database, and use this data when required.

To set the Culture and UICulture of a page by code (for example by matching the user’s selection on the browser) the following code is required:

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.UserLanguages[0]);

Convert existing encodings. ASP.NET pages are handled in Unicode. To specify the Encoding that the browser will receive, use the <%@Page ResponseEncoding="..."%> directive.

If the Encoding must be set on all the files of the web application, it must be declared in the web.config file, using the fileEncoding attribute of the globalization element:

Page 23: Webapps (mcad)

C# .NET Web Apps (70-315)

<globalization

fileEncoding="utf-8"

/>

Implement right-to-left and left-to-right mirroring. To enable Right-To-Left mirroring in web applications, simply use the DIV HTML statement with the attribute dir=”rtl” surrounding the text that must be mirrored.

This is useful for RTL languages such as Hebrew, Chinese, etc.

Prepare culture-specific formatting. MSDN – Formatting for Different Cultures

Generally the ToString method is used to convert any type into a string.

There are overloaded versions of the ToString method that allow specifying the format to use to convert the type into the string. The first method allows you to specify a format string (like “C” for currency), and uses the current culture. The other methods allow specifying an IFormatProvider derived class (like CultureInfo, DateTimeFormatInfo and NumberFormatInfo) that can specify another culture’s information.

public string ToString(string);

public string ToString(IFormatProvider);

public string ToString(string, IFormatProvider);

For example, it’s possible to format a number using a different culture other than the current one.

int MyInt = 100;

CultureInfo ItalianCulture = new CultureInfo("it-IT");

String MyString = MyInt.ToString("C", ItalianCulture);

Response.Write(MyString);

Page 24: Webapps (mcad)

C# .NET Web Apps (70-315)

Handle events. Events can occur at the application, session, page or server control level.

Application events are:

Application_Start – Called when the first user visits the first page of the Web Application

Application_End – Called before the Web Application will be disposed

Application_BeginRequest – Called at the beginning of each request

Application_EndRequest – Called at the end of each request

Session events are:

Session_Start – Called every time a new user visits its first page

Session_End – Called when the timeout of a user’s session occurs

Page level events are:

Page_Init – Called at the beginning of the processing of a page to populate server controls with their value from the ViewState

Page_Load – Called when the Page_Init is ended

Page_PreRender – Called before rendering the page

Page_UnLoad – Called before unloading the page

Page_Error – Called if there is an untrapped error

Page_AbortTransaction – Called if a transaction is aborted

Page_CommitTransaction – Called if a transaction is committed

Page_DataBinding – Called when one or more control is bound to a data source

Page 25: Webapps (mcad)

C# .NET Web Apps (70-315)

Page_Disposed – Called when the page is next to be disposed

Server control events can occur on both client-side and server-side and are divided into three categories:

Post-Back events – These client-side events cause the Web page to be sent back to the server, and then server-side events are raised.

Cached events – These client-side events are cached in the ViewState and will be processed when a Post-Back event is raised. Cached events are immediately processed like Post-Back events if AutoPostBack property is set to true.

Validation events – These events can occur at the client and also at the server.

Create event handlers. To create default event handlers simply double click the control and the event handler is created automatically.

To create non-default event handlers, simply go to the properties window, select the event tab ( ), and double click the desired event. If the event handler already exists, simply select it in the dropdown menu instead of double clicking it.

To bind an event handler to the event by code use += operator:

control.Event += new System.EventHandler(MyEventHandler);

An event can be bound and unbound with the += and -= operators.

Raise events. To raise an event server-side, simply call the event handler by invoking control.event(sender, eventargs).

To raise a server-side event from an HTML page in the browser, a Jscript code that calls the RaisePostBackEvent method is required.

Page 26: Webapps (mcad)

C# .NET Web Apps (70-315)

Use and edit intrinsic objects. Intrinsic objects include response, request, session, server, and application. The Request object (derived from HttpRequest object) is used to read information about the request that the browser has made. Here are the most important properties of the object:

Browser – Contains information about the browser that has required the page, such as the major and minor version, the model, if it supports cookies, etc.

ClientCertificates – Contains all the client certificates that the browser has sent to authenticate the client.

Cookies – Contains the cookies that the browser has sent to the server.

Files – Contains the files that were (eventually) uploaded by the client.

InputStream – Allows the reading of raw data from the stream that the browser has sent to the server.

QueryString – Contains all the parameters that were sent on the query string or via a GET request

Form – Contains all the values that were submitted via a POST request

The Response object (derived from HttpResponse object) is used to send data to the browser. Here is a list of its most important properties and methods:

Cache – Allows controlling the caching of the page

Cookies – Allows writing cookies to the browser

Write – Allows writing directly to the output stream

Binarywrite – Allows writing binary data

The Server object (derived from HttpServerUtility object) contains a set of utilities that are useful when developing Web Applications, such as HtmlEncode and HtmlDecode, UrlEncode, etc.

The Session object (derived from HttpSessionState object) contains data that are related to a particular user, and that are accessible when that user accesses a page.

The Application object (derived from HttpApplication object) contains data that are common for every user of the application, and that remain valid after the Web Application is disposed.

Page 27: Webapps (mcad)

C# .NET Web Apps (70-315)

Creating and Managing Components and .NET Assemblies Create and modify a .NET assembly. Create and implement satellite assemblies. MSDN – Creating satellite assemblies

Satellite assemblies contain only resource files and no code. Satellite assemblies can be replaced or updated without modifying the main assembly.

Satellite assemblies can be generated with Visual Studio.NET or via the Assembly Linker (al.exe).

Create resource-only assemblies. Go to Project Menu and select Add New Item, and then choose Assembly Resource File.

If you want to create a localized resource file, add the culture identifier (i.e., it-IT or de-CH) to the resource name.

To use a resource, simply create a ResourceManager:

ResourceManager resMan = new ResourceManager(“Namespace.Resource”, Assembly.GetExecutingAssembly());

and then get all the information from the resource:

Response.Write(resMan.GetString("strMessage"));

If there are localized versions of the same assembly, the right one is selected.

Page 28: Webapps (mcad)

C# .NET Web Apps (70-315)

If there isn’t the correct resource file, the default one is loaded.

Create custom controls and user controls. Web user controls are similar to Web form pages in that they can be prepared visually using the Visual Studio designer. However, they don’t offer good support for consumers that use the Visual Studio designer.

Web custom controls are controls that are created only with code, but they offer great support for consumers.

Here are the main differences between the two types of controls:

Web user controls Web custom controls

Easier to create (with visual designer) Harder to create (with code only)

Limited support for consumers who use VS.NET (that shows only a placeholder), and cannot be added to the VS.NET ToolBox

Full VS.NET support, and can also be inserted in the ToolBox

Must be inserted in each application that uses it There can be only one copy in the GAC

Typically used with static layout Typically used with dynamic layout

Creating a Web user control

Web user controls are web pages with the .ascx extension. Web user controls cannot contain <HTML>, <BODY>, <FORM> elements, which must be contained in the page that hosts the control.

It’s possible to create them by using the HTML editor or by using the visual designer, selecting the Add New Item and then selecting Web User Control.

Creating a Web custom control

Custom controls are controls that are implemented with code.

A custom control can derive from System.Web.UI.Control if it hasn’t a UI, or it can derive from System.Web.UI.WebControls.WebControl if it has a UI and needs some properties like ForeColor, BackColor, Width, Height, BorderStyle, Font, etc.

Page 29: Webapps (mcad)

C# .NET Web Apps (70-315)

Consuming and Manipulating Data Access and manipulate data from a Microsoft SQL Server™ database by creating and using ad hoc queries and stored procedures. To access and manipulate data from a Microsoft SQL Server database, the Transact SQL language is used.

The most important commands are:

SELECT – Used to retrieve data stored into the database

INSERT – Used to insert new rows into the database

UPDATE – Used to change data into the database

Stored procedures are T-SQL commands stored in the database for later use.

Using stored procedures to access a SQL Server database provides these advantages:

SQL statements are pre-compiled and execute faster

Syntax is checked at compile time, not every time

Stored Procedures remain in the cache of the database

Network traffic is low because the code is in the database

Stored Procedures can be shared between applications, allowing code reuse

Stored Procedures provide better security

Access and manipulate data from a data store. Data stores include relational databases, XML documents, and flat files. Methods include XML techniques and ADO .NET. ADO.NET is the preferred technique to access data in the .NET Framework.

ADO.NET supports various types of data storage:

Relational databases (SQL Server, Oracle, etc.)

Page 30: Webapps (mcad)

C# .NET Web Apps (70-315)

Hierarchical data (XML files)

Structured data (CSV, Excel, Active Directory, etc.)

Unstructured data

ADO.NET supports two different environments:

Connected

Disconnected.

A connected environment requires a continuous connection with the data source. A disconnected environment allows retrieving data, releasing the connection, manipulating the data, reopening the connection and storing the data back into the data source.

ADO.NET is composed of a series of classes, interfaces, structures and enumerations grouped in a series of namespaces:

System.Xml

System.Data

System.Data.Common

System.Data.SqlTypes

System.Data.SqlClient

System.Data.OleDb

The last two namespaces are used to access data. The first is used to access SQL Server 7.0 and SQL Server 2000, and the second is used for all the other OLE DB data sources. Other data access providers (with their namespace) are coming (ODBC, Oracle, DB2, MySql, etc.))

Page 31: Webapps (mcad)

C# .NET Web Apps (70-315)

To access data in a connected environment, three classes are involved:

xxxConnection – Used to establish a connection to a specific data source

xxxCommand – Used to execute a command from a data source

xxxDataReader – Used to read a forward-only, read-only stream of data

where xxx can be Sql for the SqlClient data source and OleDb for the OleDb data source.

A wizard helps to set up a connection to the database:

To access data in a disconnected environment two other classes are involved:

xxxDataAdapter – Uses the xxxConnection, xxxCommand and xxxDataReader classes to populate a DataSet and to update the data source with the changes made to the DataSet

Page 32: Webapps (mcad)

C# .NET Web Apps (70-315)

DataSet – A class that encapsulates a set of tables and their relationship. Every operation made to the DataSet can be replicated to the data source using the xxxDataAdapter.

There is a wizard that helps to configure a DataAdapter:

Page 33: Webapps (mcad)

C# .NET Web Apps (70-315)

After that the data adapter is created, it can be used to obtain a DataSet with a wizard:

XML is an important part of data access, because it’s possible to retrieve an ADO.NET DataSet and see it as an XML document or vice versa. It’s also possible to fill a DataSet with XML data.

Handle data errors. ADO.NET classes throw exceptions if something goes wrong.

Every .NET data provider has an exception class:

SQLException (has an Errors collection that contains SqlError objects)

OleDbException (has an Errors collection that contains OleDbError objects)

It’s important to enclose ADO.NET code in Try..Catch..Finally statements in order to properly handle errors, and to execute the clean-up code when needed.

The xxxError object has some properties like:

Page 34: Webapps (mcad)

C# .NET Web Apps (70-315)

Class – The severity level of the error

LineNumber – The line number within the SQL stored procedure or batch file

Message – The text that describes the error

Number – The error code

Testing and Debugging Create a unit test plan. With unit testing you test every unit separate from the rest of the application to determine if it behaves as expected.

The most common approach to unit testing requires the implementation of drivers and stubs. Drivers are used to simulate a call from another unit, whereas stubs are used to simulate a called unit.

Implementing drivers and stubs is expensive, and sometimes unit testing is not implemented or has a low priority in the project. This is a great mistake, because it’s proven that a large percentage of bugs are identified during these kinds of tests. Moreover, trying to discover errors across the entire application is more complicated than finding them in every single unit.

Implement tracing. There are two classes used to trace debugging or other information when the program runs:

Debug – Used to print debugging information when the project is built in Debug mode.

Trace – Used to print information when the program is in Release mode. Traces can be enabled or disabled with trace switches.

Both classes share a set of methods:

Write, WriteLine – They always send the information to the trace listener.

WriteIf, WriteLineIf – They send the information to the trace listener if the condition is true.

Page 35: Webapps (mcad)

C# .NET Web Apps (70-315)

Assert – Tests a condition and stops the program execution if it’s false

Fail – Causes a termination of the program.

Add trace listeners and trace switches to an application. Trace listeners are used to collect, store and route tracing messages.

Tracing messages can be logged, printed or stored on a file.

Listeners can be used with both Debug and Trace classes. Three types of listeners are already implemented in the .NET Framework:

DefaultTraceListener – It’s the default behavior of both Trace and Debug classes. It sends messages to OutputDebugString and calls the Debugger.Log method (in Visual Studio.NET this sends the messages to the Output window).

In addition to this behavior, Fail and failed Assert generate a message box.

EventLogTraceListener – It sends the messages to an event log.

TextWriterTraceListener – It sends the messages to an instance of the TextWriter class or to a Stream derived class.

To add a listener to Debug or Trace classes simply create it and add it to the Listener’s collection of one of them.

Here is an example:

System.IO.FileStream myTraceLog = new

System.IO.FileStream("C:\\myTraceLog.txt",

System.IO.FileMode.OpenOrCreate);

TextWriterTraceListener myListener = new

TextWriterTraceListener(myTraceLog);

Trace.Listeners.Add(myListener);

It’s also possible to create a Listener and use it without adding it to the Debug or Trace classes.

Simply use the Write or WriteLine methods of the listener, but remember to call the Flush method at the end. This is not required if the listener is added to the Listener’s collection.

Page 36: Webapps (mcad)

C# .NET Web Apps (70-315)

Trace switches are used to enable or disable tracing. There are two types of predefined switches:

BooleanSwitch – Enables or disables tracing at all.

TraceSwitch – Enables or disables tracing based on the level of the message (Off, Error, Warning, Info, Verbose in increasing order). When a level is selected, all the lower levels are selected.

Here is an example:

TraceSwitch myTraceSwitch = new TraceSwitch("MySwitch", "Description");

myTraceSwitch.Level = TraceLevel.Info;

Trace.WriteLineIf(myTraceSwitch.TraceError, "It’s displayed because it’s lower then Info");

Trace switches can also be configured with the XML configuration file using:

<system.diagnostics>

<switches>

<add name="MySwitch" value="0" />

</switches>

</system.diagnostics>

Where 0 corresponds to Off and 4 to Verbose.

Display trace output. Trace output can also be sent to the browser using the directive <%@ Page Trace="true"%>. Trace output can also be sorted adding the directive TraceMode=”…” to the previous directive.

Enabling Trace not only allows displaying information from the Trace class, but tells the ASP.NET runtime to generate complete trace information of all the events, server variables, cookies, etc. on the page.

Page 37: Webapps (mcad)

C# .NET Web Apps (70-315)

With Tracing enabled on the browser, it’s also possible to use the Trace.Warn statement, which prints the trace text in red.

Debug, rework, and resolve defects in code. Configure the debugging environment. To set up the debugging environment use the Tool menu, Options and then go to Debugging folder.

Most of the options are under General:

Page 38: Webapps (mcad)

C# .NET Web Apps (70-315)

In the Edit and Continue tab you can set enable the feature for each .NET language.

Just-In-Time enables the Just-In-Time debugging.

Native enables RPC debugging and Load DLL export.

Create and apply debugging code to components, pages, and applications. Debug methods are the same as the Trace class.

To enable debugging on a Web application, the debug=”true” attribute of the <compilation> tag in the Web.config file must be set. This enables the generation of debugging information for the compiled pages, but slows down the execution and then compilation of the pages.

Provide multicultural test data to components and applications. It’s very difficult to manually enter test inputs in different languages (Arabic, Hebrew, Thai, East Asian languages, German, Greek, etc.). In some cases these limitations that are not trivial to understand.

It’s better to use a Unicode text generation utility that can generate text according to different languages’ rules.

It’s also very important to test how the Web application is rendered in different cultures. English strings are generally shorter than those of any other language.

Page 39: Webapps (mcad)

C# .NET Web Apps (70-315)

Execute tests. It’s important to have some test machines that allow testing for different configurations. For example, if the Web application is localized it’s important to test it with different representative user locale, like German to test Western Europe characters, and Japanese to test East Asian characters.

It’s possible to instruct the Browser to request pages in different languages. Moreover, it’s very important to use multiple browsers and multiple versions of the same browser to test how the pages are rendered on each of them.

Resolve errors and rework code. It’s very easy to modify pages and components because pages are recompiled if changed, and DLL’s are not locked in memory and can be replaced simply by overwriting them (by using the shadow copy technique, the DLL is copied and the copy is loaded in memory).

So modifying code is possible even when the application is deployed and is running.

Deploying a Web Application Plan the deployment of a Web application. Deploy a Web application by creating a Windows Installer (.msi) file, or by copying all the files to the appropriate directory on the target machine.

The .msi file is more practical if deploying the application using a removable media (like CD-ROM), while copying all the files is easier on a network (for example using FTP to deploy the application).

Create a setup program that installs a Web application and allows for the application to be uninstalled. Use the Web Setup Project to create a new Windows Installer file.

Page 40: Webapps (mcad)

C# .NET Web Apps (70-315)

It’s then possible to add files to the Web Application Folder, and to its bin subfolder. It’s also possible to add other special directories to the project.

You can check for the existence of the IIS, to edit the target machine registry, to add components to the GAC (Global Assembly Cache), etc.

After building the solution, these files are generated:

where InstMsiA.exe, InstMsiW.exe, Setup.exe and Setup.Ini are the Windows Installer 2.0 installation files and Setup2.msi is the Windows Installer file.

Deploy a Web application. To deploy a Web application, run the Windows Installer file created with the Web Setup Project. If the Web application doesn’t refer to components in the GAC or doesn’t require modifications to other parts of the system, you can also use FTP or XCOPY to deploy the application.

By simply copying the application to the appropriate directory on the target machine, the application should run without other modifications.

Page 41: Webapps (mcad)

C# .NET Web Apps (70-315)

You may also run different versions of the same Web application side-by-side on the same Web server.

Add assemblies to the Global Assembly Cache. The Global Assembly Cache (GAC) is used to store assemblies that can be shared among many applications. It can store one or more versions of the same assembly (side-by-side deployment).

Assemblies must have a Strong Name because of the strict naming rules used to ensure that the correct assembly is loaded when requested.

Administrator privileges are required to install or uninstall an assembly in the GAC.

Windows Installer or the .NET Framework configuration tool (MSCORCFG.MSC) can be used to install assemblies.

In development environments, the GACUtil can be used for testing purposes.

GACUtils options are:

/i or –i Install an assembly into the GAC

/l or –l List the contents of the GAC

/u or –u Uninstall one or more assemblies

The .NET installer installs a shell-extension that displays extended information about the assemblies on the GAC in Windows Explorer:

Page 42: Webapps (mcad)

C# .NET Web Apps (70-315)

Maintaining and Supporting a Web Application Optimize the performance of a Web application. There are several ways to optimize the performance of a Web application:

Use caching to store and retrieve data, fragments and whole pages without re-executing them

Optimize database queries

Use tracing to determine how much time was taken by every piece of the page and try to optimize them

Disable sessions that aren’t necessary, or use the fastest state provider that is compatible with other issues (like Web farms, reliability, etc.)

Limit the use of exceptions

Use Response.Write to concatenate strings: this is faster than using string concatenation

Use Page.IsPostBack to avoid recalculating some parts of the page

Page 43: Webapps (mcad)

C# .NET Web Apps (70-315)

Limit the use of server controls

Limit the use of the viewstate

Diagnose and resolve errors and issues. Use Tracing to look at which events are executed, and use the Visual Studio Debugger to steps into page errors.

Remember to look at HTML source that is received by the browser, because it’s possible to find what doesn’t work by looking at the HTML code generated by Web or HTML controls.

Configuring and Securing a Web Application Configure a Web application. ASP.NET offers a simple but powerful way to configure Web applications: information is stored in XML-based text files, and is thus editable with a simple text editor and also while the application is running (the new settings are applied at the first page execution). The <processModel> section is the only part that cannot be edited at runtime. Look here for a complete list of all the available elements.

Modify the Web.config file. There can be multiple Web.config files in each virtual directory and sub-directory. The settings are applied in hierarchical order (from the top level directory to the sub-directories).

Modify the Machine.config file. The Machine.config file is used to set machine-wide settings, and is at the top of the hierarchy.

Add and modify application settings. Application settings can be stored in the <appSettings> section of the Web.config file.

<configuration>

<appSettings>

<add key="myPar" value="myParValue" />

</appSettings>

</configuration>

Page 44: Webapps (mcad)

C# .NET Web Apps (70-315)

They can be read using the ConfigurationSettings.AppSettings static string collection.

String myParameter = ConfigurationSettings.AppSettings[“myPar”];

Configure security for a Web application. Select and configure authentication type. Authentication types include Windows® Authentication, None, forms-based, Microsoft Passport, Internet Information Services (IIS) authentication, and custom authentication. Authentication is used to identify users by using credentials like a name and a password and validating them against an authority.

ASP.NET implements authentication through authentication providers:

Windows authentication Windows authentication is performed by IIS in three ways: basic, digest, and integrated.

Where basic is supported by all the browsers, digest by most of them and integrated only by Internet Explorer.

Form authentication An HTML form is invoked to authenticate an unknown user. If the user supplies a valid user name and password, it can access all the authorized resources.

Passport authentication Is a centralized authentication service provided (on a subscription base) by Microsoft.

To enable an authentication provider for an ASP.NET application, simply add the <authentication> element to the Web.config file:

<authentication mode= "[Windows/Forms/Passport/None]"/>

Using mode=”None” allows implementing a custom authentication all by code.

Configure authorization. Authorization methods include file-based methods and URL-based methods. Configure role-based authorization. Authorization is used to check if a user has access to a particular resource.

Role-based security is based on two main concepts:

Identity – Normally the user’s log on name

Principal – Roles associated with a user, like Windows users and groups or custom roles

Page 45: Webapps (mcad)

C# .NET Web Apps (70-315)

There are two authorization providers:

File authorization – Used with Windows authentication and uses windows ACLs to determine if a user can access a resource.

URL authorization – Used with all authentication providers and maps users and roles to pieces of the URL, giving positive and negative authorization assertions.

Here is an example of an URL authorization:

<authorization>

<allow users="xxx"/>

<deny users="yyy" />

<deny users="?" />

</authorization>

The above must be set in the Web.config file of the specified URL path. ? and * are special identities associated with the anonymous user and with all the users.

Implement impersonation. Impersonation is the ability to execute an ASP.NET application with a user that is not the client user.

Impersonation is disabled by default and must be enabled by changing the Web.config file:

<identity impersonate="true" userName=”xxx” password=”yyy” />

Configure and implement caching. Caching types include output, fragment, and data. Use a cache object, cache directives. Caching is used to increment the performance of a Web application. You may cache an entire page, a fragment of a page or data.

To cache an entire page the @ OutputCache directive can be used and the Duration and VaryByParam attributes are required. The VaryByParam attribute allows caching multiple versions of a Page.

Page 46: Webapps (mcad)

C# .NET Web Apps (70-315)

It’s also possible to use a low-level set of APIs by using the HttpCachePolicy class, available through the HttpResponse.Cache property or from the Page.Response property of the Page object.

It’s possible to cache a fragment of a page by encapsulating it in a Web control. Then the @ OutputCache directive can be applied to it. You may also specify the [PartialCaching(xxx)] attribute.

To cache data, the Cache object is used. To add an element, use the Cache.Add and Cache.Insert methods. To retrieve an item simply use the Cache[“key”] notation.

The Cache object can delete some objects if doesn’t have enough memory. If an object is deleted, trying to access it returns a null pointer. Typically, it’s a good idea to catch this exception and recreate the object in the cache for a later use.

Configure and implement session state in various topologies such as a Web garden and a Web farm. A Session state can be stored in memory, in a session state service or in SQL Server. The first is the fastest way; the last is the most secure.

The first can be used only with one Web Server, while the others can also be used with a Web garden and Web farm.

To configure how to store the session state, use the Web.config file.

Use session state within a process. To store sessions in memory, simply configure the <sessionState> element in the Web.config file with the mode=”inproc” attribute.

Use session state with session state service. To use the State Service, it must be installed on the target machine with the aspnet_estate.exe program (it is installed by the ASP.NET Premium edition in the folder Drive:\Program Files\ASP.NET\Premium\version\ directory).

Next, the <sessionState> element in the Web.config file must include the mode=”StateServer” and stateConnectionString = ”tcpip=remoteServer:42424” attributes.

Page 47: Webapps (mcad)

C# .NET Web Apps (70-315)

Use session state with Microsoft SQL Server. To use SQL Server, configure it by running the InstallSqlState.sql script on the server. This prepares all the tables and the stored procedures (in the ASPState database) used to store the session state.

Next, the <sessionState> element in the Web.config file must include the mode=”SQLServer” and sqlConnectionString = ”data source=remoteServer; user id=xxx; password= xxx” attributes.

Install and configure server services. Install and configure a Web server. IIS is the Web server used to host ASP.NET pages. IIS can host multiple sites on a single computer, and multiple virtual directories on a single site.

Remember to check the following security issues:

Check Web and NTFS permissions: if they are different, the most restrictive ones are used.

Use IP address restriction on the administration pages if you enable remote administration

Use the most restrictive permission possible: if you use the site only for static content, enable only the read permission; if you use ASP but no other executables, enable Script Only permissions instead of Script and Executables

Use Write permissions with extreme caution, especially if you use ASP or other executables, because a malicious user can upload unsafe code to the server and then execute it.

To authenticate users, use the most secure method. Basic Authentication sends the password in clear, but it is compatible with all the browsers. Windows Integrated and Digest are more secure but require Internet Explorer.

You can also use certificates to authenticate users. You can map the certificate to the user one-to-one or one-to-many. The first is most secure, but the second is easier to implement and maintain.

Set the number of users in the performance tab according to the expected traffic on your site. The three possibilities are fewer than 10,000, fewer than 100,000 and more than 100,000.

For more information about configuring IIS, see:

TECHNET- Deploying IIS

After the installation of IIS, the installation of the .NET Framework on the machine enables the execution of ASP.NET pages (that aren’t supported by IIS alone).

Page 48: Webapps (mcad)

C# .NET Web Apps (70-315)

Install and configure Microsoft FrontPage® Server Extensions. FrontPage Server Extensions are a set of ISAPI filters that enable remote administration of web sites.

The Windows Component Update CD-ROM contains FP Server Extensions, which are also available on the Microsoft site.

To install FrontPage Server Extensions, refer to the installation guide.