Vous êtes sur la page 1sur 30

Developing Web Applications Using ASP.

NET
Objectives

In this session, you will learn to:


Monitor Web applications Create mobile Web pages Render content on mobile Web pages

Ver. 1.0

Slide 1 of 30

Developing Web Applications Using ASP.NET


Monitoring Web Applications

After deploying a Web application, a System Administrator needs to constantly monitor the application for its proper functioning. By monitoring a Web application, you can detect the problems occurring in the application and troubleshoot them. Monitoring and troubleshooting are required to improve the performance of a Web application. To help you track monitor a Web application, ASP.NET provides you with the following two features:
Health monitoring Performance monitoring

Ver. 1.0

Slide 2 of 30

Developing Web Applications Using ASP.NET


Health Monitoring

ASP.NET health monitoring system:


Enables you to monitor the status of the deployed Web applications. Is used to track system events and errors, which can hamper the performance of a Web application. Enables you to get the detailed run-time information about ASP.NET resources used by a Web application. Is implemented by using the System.Web.Management namespace.

Ver. 1.0

Slide 3 of 30

Developing Web Applications Using ASP.NET


Health Monitoring (Contd.)

You can configure applications to use built-in or customized monitoring providers. To use the health monitoring system you need to:
Configure and enable Web events to monitor. Configure and enable event providers that listen for and process various Web events.

Web events contain information about the health of a Web application.

Ver. 1.0

Slide 4 of 30

Developing Web Applications Using ASP.NET


Health Monitoring (Contd.)

There are several events that you can trap to monitor the health of a Web application. Some of the important events are:
WebBaseEvent WebBaseErrorEvent WebHeartbeatEvent WebRequestEvent WebErrorEvent WebApplicationLifetimeEvent WebRequestErrorEvent WebAuditEvent WebFailureAuditEvent

Ver. 1.0

Slide 5 of 30

Developing Web Applications Using ASP.NET


Health Monitoring (Contd.)

The event providers are used to listen for Web events that are raised by a Web application. Some of the built-in providers are:
EventLogWebEventProvider SqlWebEventProvider SimpleMailWebEventProvider and TemplatedMailWebEventProvider TraceWebEventProvider WmiWebEventProvider

Ver. 1.0

Slide 6 of 30

Developing Web Applications Using ASP.NET


Performance Monitoring

Performance is an important factor in making a Web application or project successful. You need to monitor a Web application to troubleshoot any performance-related issues. You need to keep a track of such errors to improve the performance of your Web application. ASP.NET provides you with several performance counters, such as Application Restarts, Requests Queued, and Errors Total to help you keep track of the execution of your Web application.

Ver. 1.0

Slide 7 of 30

Developing Web Applications Using ASP.NET


Performance Monitoring (Contd.)

ASP.NET supports the following two groups of performance counters:


System performance counters Application performance counters

Ver. 1.0

Slide 8 of 30

Developing Web Applications Using ASP.NET


Performance Monitoring (Contd.)

The following table lists some of the system performance counters.


System Performance Counter Application Running Requests Disconnected Request Wait Time Description Represents the number of applications running simultaneously on a Web server. Represents the number of requests that have been disconnected due to a communication failure. Represents the number of milliseconds that the most recent request waited in the queue for being processed by the server. Represents the number of user sessions that have become inactive because of some user action. This counter is available only on the computer where the state server service, aspnet_state is running. Represents the number of worker processes running on a Web server.

State Server Sessions Active

Worker Process Running

Ver. 1.0

Slide 9 of 30

Developing Web Applications Using ASP.NET


Performance Monitoring (Contd.)

The following table lists some of the application performance counters.


Application Performance Counter Anonymous Requests Anonymous Requests/Sec Cache Total Entries Cache Total Hits Debugging Requests Description Represents the number of requests that are using anonymous authentication. Represents the number of requests per second that are using anonymous authentication. Represents the total number of entries in the cache. Represents the total number of hits from the cache. Represents the number of requests that occur while debugging is enabled.

Let us see how to configure performance counters by using system monitor

Ver. 1.0

Slide 10 of 30

Developing Web Applications Using ASP.NET


Creating Mobile Web Pages

Mobile devices have many limitations such as small display area and low bandwidth. Due to these limitations, a Web page created for desktop browsers cannot be properly displayed on mobile devices. You need to create specifically designed Web pages for mobile devices. ASP.NET provides you with the System.Web.Mobile namespace that is used specifically for mobile Web development. The System.Web.Mobile namespace contains the core capabilities such as authentication and error handling, required for building ASP.NET mobile Web applications.

Ver. 1.0

Slide 11 of 30

Developing Web Applications Using ASP.NET


Working With Mobile Web Controls

The ASP.NET mobile Web controls are contained in the System.Web.UI.MobileControls namespace that provides the user interface elements for rendering mobile Web applications. Some controls that are specific to the mobile Web pages are:
Form control Command control PhoneCall control List and ObjectList control DeviceSpecific control SelectionList control StyleSheet control TextView control
Ver. 1.0

Slide 12 of 30

Developing Web Applications Using ASP.NET


Working With Mobile Web Controls (Contd.)

Form control:
A Form control is a container control that provides the capability to group controls together. Each Form control can hold a group of logically related controls. The Form controls can be displayed by setting the ActiveForm property of the Web page.

Command control:
A Command control combines the functionality of the normal Button, ImageButton, and LinkButton controls. The Command control has properties similar to that of the Button server control. The Command control can be added to a mobile page by using the <Command> element.

Ver. 1.0

Slide 13 of 30

Developing Web Applications Using ASP.NET


Working With Mobile Web Controls (Contd.)

PhoneCall control:
A PhoneCall control is used to enable applications to initiate telephone calls if the user's mobile device supports the capability of placing phone calls:
If the mobile supports the capability, the phone number specified by using PhoneNumber property of the PhoneCall control is displayed as hyperlink. If the mobile device does not support the capability, the PhoneCall control displays the phone number as text.

The PhoneCall control can be added to a mobile page by using the <PhoneCall> element. To use a PhoneCall control, you need to:
Add the control onto a Form or Panel control or inside a control's template on an ASP.NET mobile Web page. Specify the Text and the PhoneNumber properties.

Ver. 1.0

Slide 14 of 30

Developing Web Applications Using ASP.NET


Working With Mobile Web Controls (Contd.)

List and ObjectList controls:


The List control includes the functionality that is provided by the DataList and Repeater controls. The List control can be added to a mobile page by using the <List> element. The ObjectList control includes the functionality that is provided by the DataGrid control. The ObjectList control can be added to a mobile page by using the <ObjectList> element.

Ver. 1.0

Slide 15 of 30

Developing Web Applications Using ASP.NET


Working With Mobile Web Controls (Contd.)

DeviceSpecific control:
The DeviceSpecific control is used to specify a choice among multiple content alternatives. The DeviceSpecific control is used to specify template sets and override properties.

SelectionList control:
The SelectionList control provides different visual representations for a list of selectable items. The SelectionList control combines the functionality of the CheckBox, CheckBoxList, DropDownList, ListBox, RadioButton, and the RadioButton Web server controls. You can use the SelectType property of the SelectionList control to define the type of selection list button to render.

Ver. 1.0

Slide 16 of 30

Developing Web Applications Using ASP.NET


Working With Mobile Web Controls (Contd.)

TextView control:
The TextView control is to display large quantities of text. The TextView control supports device filters for overriding property values. The TextView control can be added to a mobile page by using the <TextView> element.

Let us see how to create a Web form for mobile devices

Ver. 1.0

Slide 17 of 30

Developing Web Applications Using ASP.NET


Working with Device Emulators

Device emulators:
Are software programs that simulate the environment of a cell phone or PDA on the desktop of your PC. Are treated as virtual mobile devices. Are available, for most mobile devices, to simulate the behavior of the hardware and browsers of the mobiles. Allow you to view mobile Web forms as they would appear on the actual mobile devices. Enable you to test your mobile Web applications before deploying.

Ver. 1.0

Slide 18 of 30

Developing Web Applications Using ASP.NET


Rendering Content on Mobile Web Pages

There are various mobile devices available in the market that have different capabilities and differ from each other in terms of:
Screen size Color combination Browser type Many other features

Due to these differences, a Web control is rendered differently on different mobile devices. Therefore, if you want to create a Web application that can run on multiple mobile devices, you need to create a separate user interface for each device, which is a tedious and complex task. This task can be simplified by using control adapters and device filters provided by ASP.NET.
Ver. 1.0

Slide 19 of 30

Developing Web Applications Using ASP.NET


Implementing Control Adapters

Mobile devices have different screen sizes and capabilities. The controls are rendered on the Web page on the basis of the capabilities of a browser that requested for the page. This type of browser-based rendering of controls is known as adaptive rendering and can be implemented by using control adapters. A control adapter is used for device-specific rendering of mobile Web controls instead of using the control's default rendering logic.

Ver. 1.0

Slide 20 of 30

Developing Web Applications Using ASP.NET


Implementing Control Adapters (Contd.)

To customize the behavior of Web controls, you need to specify an object of the ControlAdapter class. The ControlAdapter class:
Is an abstract class that defines the basic functionality for all adapters. Overrides certain methods and events of the Control class to allow browser or markup-specific handling.

Ver. 1.0

Slide 21 of 30

Developing Web Applications Using ASP.NET


Implementing Device-Specific Rendering

Different mobile devices have different capabilities. Therefore, you should design a Web page that caters to all the possible types of mobile devices. The ability to render a control based on the type of the device is known as device-specific rendering. This requires you to set the properties of the controls based on the capabilities of the mobile devices by using device filters. ASP.NET allows you to specify device filters for each type of device by using the <DeviceSpecific><Choice> tags. You can insert the <DeviceSpecific> tag as a child element of any mobile control on the Web page.

Ver. 1.0

Slide 22 of 30

Developing Web Applications Using ASP.NET


Implementing Device-Specific Rendering (Contd.) The <Choice> tag represents device characteristic/value pairs, where the device characteristic is drawn from a number of sources. A control can contain only one <DeviceSpecific> tag, but many <Choice> tags. Choices are evaluated in the order in which they appear in the DeviceSpecific/Choice construct. Each <Choice> tag contains:
A Filter attribute that specifies the devices that this choice applies to. Additional property values that override the properties of the original control when the device specified by the Filter attribute is used.

Ver. 1.0

Slide 23 of 30

Developing Web Applications Using ASP.NET


Implementing Device-Specific Rendering (Contd.)

When the name of a method is used as a filter, the choice is applied on the basis of the Boolean value returned by the method. The filter method must conform to the following signature:
public bool methodName( System.Web.Mobile.MobileCapabilities capabilities, string optionalArgument);

Ver. 1.0

Slide 24 of 30

Developing Web Applications Using ASP.NET


Implementing Device-Specific Rendering (Contd.) The Filter attribute can also specify the name of a filter defined in the web.config file. These filters can be of two types:
Comparison filter Evaluator delegate filter

Ver. 1.0

Slide 25 of 30

Developing Web Applications Using ASP.NET


Activity 15.1: Creating a Web Form for Mobile Devices

Problem Statement:
The management of MusicMania has decided to make its Web application available on mobile devices. In the initial phase, you are only required to create the MobileMusic.aspx page that should be displayed as the home page when a user requests for the MusicMania website. This page should contain two forms, frmHome and frmAlbum. When a mobile device requests for the home page, the frmHome form should be displayed on the MobileMusic page. This form should display the colored logo of the company. There should also be a button, DisplayAlbumDetails, on the frmHome form. When the user clicks this button, the frmAlbum form should be displayed. The frmAlbum form should display the details of the latest album.

Ver. 1.0

Slide 26 of 30

Developing Web Applications Using ASP.NET


Activity 15.1: Creating a Web Form for Mobile Devices (Contd.)

Solution:
To design the MobileMusic page, you need to perform the following tasks:
1. Add a new Web Page. 2. Design the new Web page. 3. Execute the application by using device emulator.

Ver. 1.0

Slide 27 of 30

Developing Web Applications Using ASP.NET


Summary

In this session, you learned that:


ASP.NET provides you with the following two features for monitoring a Web application:
Health monitoring Performance monitoring

ASP.NET supports the following two groups of performance counters:


System performance counters Application performance counters

A Web page created for desktop browsers cannot be properly displayed on mobile devices because mobile devices have small display area and low bandwidth. ASP.NET provides you with the System.Web.Mobile namespace that is used specifically for mobile Web development.

Ver. 1.0

Slide 28 of 30

Developing Web Applications Using ASP.NET


Summary (Contd.)

Mobile Web pages have some specific controls. These are:


Form Command PhoneCall List and ObjectList DeviceSpecific SelectionList StyleSheet TextView

Device emulators are software programs that simulate the environment of a cell phone or PDA on the desktop of your PC. A control adapter is used for device-specific rendering of mobile Web controls instead of using the control's default rendering logic.

Ver. 1.0

Slide 29 of 30

Developing Web Applications Using ASP.NET


Summary (Contd.)

To customize the behavior of Web controls, you need to specify an object of the ControlAdapter class. The ControlAdapter class is an abstract class that defines the basic functionality for all adapters. The ability to render a control based on the type of the device is known as device-specific rendering.

Ver. 1.0

Slide 30 of 30

Vous aimerez peut-être aussi