Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ASP .NET 2.0 Beta Preview - B. Evjen.pdf
Скачиваний:
26
Добавлен:
24.05.2014
Размер:
15.33 Mб
Скачать

Administration and Management

Figure 14-23

Managing the Site Counter System

Another outstanding management feature is ASP.NET’s capability to monitor the views and clicks occurring in an application. Not only does the new site counter system count the views and clicks that occur as end users work through your Web application, it also generates reports in the browser with the site counter results.

To see an example of the new site counter system, begin by working with the ASP.NET Web Site Administration Tool. Open WAT and click the Configure Counter Settings link on the Application tab. You see a page dealing with counters, as shown in Figure 14-24.

407

Chapter 14

Figure 14-24

On this screen, make sure that the Enable Counter For Controls check box is checked. Then, in the text box labeled Specify How Many Rows Per Day of Site Statistics Will Be Written to the Database, keep the default of 1. One row in the database is used to store the counts. For the rest of the options, make sure the Track Application Name and Track Page URL check boxes are checked. Give your created site counter configuration a name and associate it to a counter group. As you can see in Figure 14-24, I gave the counter the name BannerAds and the counter group the name PageCounters. Finally, save your configuration by clicking the Save button in the lower-right corner of the dialog.

This operation has changed your web.config file. The results are shown in Listing 14-1.

Listing 14-1: Enabling the web.config for the site counter system

<?xml version=”1.0”?> <configuration>

<system.web>

<siteCounters defaultProvider=”AspNetAccessProvider” enabled=”true” rowsPerDay=”1”>

<pageCounters enabled=”true” trackApplicationName=”true” trackPageUrl=”true” counterName=”BannerAds”

408

Administration and Management

counterGroup=”PageCounters” /> </siteCounters>

</system.web>

</configuration>

Remember that although it is possible to work with tools such as WAT to build all this for you in the application’s configuration file, you can also place all the information in the web.config file yourself. The best approach is whatever is easier for you in the end.

Now that you have configured the web.config file to work with control clicks, learn how to monitor button clicks and views of an AdRotator server control. This is a common scenario because many Web sites sell advertising and charge their clients based on views, clicks, or both. Not only will the site counter system tally these items for you, but it also provides the GUI reports of what was tallied. Listing 14-2 shows an AdRotator control enabled to work with the site counter system.

Listing 14-2: A server control working with the site counter system

<%@ Page Language=”VB” %>

<html xmlns=”http://www.w3.org/1999/xhtml” > <head runat=”server”>

<title>AdRotator Page</title> </head>

<body>

<form id=”form1” runat=”server”>

<asp:AdRotator ID=”AdRotator1” Runat=”server” AdvertisementFile=”MyAds.xml” CountViews=”true” CountClicks=”true” />

<p>Lorem ipsum dolor sit

amet, consectetuer adipiscing elit. Duis vel justo. Aliquam adipiscing. In mattis volutpat urna. Donec adipiscing, nisl eget dictum egestas, felis nulla ornare ligula, ut bibendum pede augue eu augue. Sed vel risus nec urna pharetra imperdiet. Aenean semper. Sed ullamcorper auctor sapien. Suspendisse luctus. Ut ac nibh. Nam lorem. Aliquam dictum aliquam purus.</p>

</form>

</body>

</html>

This AdRotator server control isn’t much different from the AdRotator server control shown in Listing 13-7 in the last chapter — although this one has a couple of new attributes. To work with the site counter system provided by ASP.NET 2.0, you add the CountViews and the CountClicks attributes. In both cases, you set these attribute values to True. The CountViews attribute enables or disables the site counter system, which records each and every time that the image shown by the AdRotator control is actually viewed in the browser. The CountClicks attribute is always a lesser number because it enables or disables the site counter system that counts the number of times an end user clicks on the advertisement.

Now that both of these attributes have been set to True and the web.config file is configured properly, you can run the application and refresh the page a few times. Click the advertisement generated by the AdRotator control a few times to generate some results for the site counter system.

409

Chapter 14

Then, with the ASP.NET Web Site Administration Tool, return to the Application tab and click the Site Counter Reports link. This pulls up details on the PageCounter’s Details page. From this page, you can see the number of page views that have been counted by the system. From the drop-down list on the page, select AdRotator. This causes WAT to pull up details about the AdRotator server control, as shown in Figure 14-25.

Figure 14-25

On this page, you can see the date the views or clicks were recorded, the page the details came from, and the ID of the server control (in this case AdRotator1). It also shows the count event (Views or Clicks), the destination URL of the control, and finally the number recorded by the site counter system.

Summar y

This chapter showed you some of the new management tools that come with the latest release of ASP.NET. These new tools make the ever-increasing size of the web.config file more manageable because the tools take care of setting the appropriate values in the application’s configuration file.

410

Administration and Management

The ASP.NET snap-in to the Microsoft Management Console is a welcome addition for managing applications that are configured to work with IIS. The ASP.NET Web Site Administration Tool provides even more value to administrators and developers as it enables them to remotely manage settings.

Finally, you learned how to use the site counter system to create detailed reports on the clicks and views that your Web application produces.

411

Visual Basic 8.0 and C# 2.0

Language Enhancements

A lot has changed with the Whidbey release of .NET. Not only are there dramatic changes to ASP.NET (as I have shown you throughout this book), but considerable changes have been made to the IDE, Windows Forms, Visual Basic, C#, and more. This chapter focuses on the changes to Visual Basic and C# languages because these are the two languages most commonly used for ASP.NET development. Because of their heavy use in Web application development, it is vital to understand the capabilities of these languages and the direction they are taking.

Probably one of the greatest changes to Web application development in the Microsoft world is

.NET’s use of true object-oriented languages such as Visual Basic .NET and C# to build Web applications. You are no longer required to work with interpreted languages. Although they have only recently been introduced to the Web application world, these object-oriented languages are continuing to evolve, bringing new features to Web application development.

This last chapter focuses on the changes that have occurred to both Visual Basic and C# with this latest release of the .NET Framework. You can apply what you learn here directly to your ASP.NET 2.0 applications.

Over view of Changes

Both Visual Basic and C# have undergone changes with the release of the .NET Framework 2.0. Some of the changes have occurred in both languages, whereas other changes have occurred in only one.