Developer .NET UPDATE, August 18, 2003

Developer .NET UPDATE—brought to you by the Windows & .NET Magazine Network

This Issue Sponsored By

DevConnections--Early Bird Discount to Expire

New Exchange Event from Windows & .NET Magazine Connections

August 18, 2003--In this issue:

1. Developer .NET Perspectives

  • The Search for the Redirection Code

2. Announcements

  • Get the eBook That Will Help You Get Certified!
  • Register Now for WinSummit 2003

3. Resource

  • Featured Thread: Trying to Create a Windows Service

4. Events

  • New--Mobile & Wireless Road Show!

5. New and Improved

  • Monitor Applications and Capture Problems

6. Contact Us

  • See this section for a list of ways to contact us.

Sponsor: DevConnections--Early Bird Discount to Expire

DevConnections = Microsoft ASP.NET Connections + Visual Studio Connections + SQL Server Magazine Connections + Microsoft Office System Connections. Four conferences for the price of one with over 170 total sessions if you register now. Plus, save $200 before the Early Bird discount expires August 29th. All session and speaker information plus the conference brochure are online.

This is your chance to get the latest roadmap from Microsoft, learn practical tips and insights that you'll use on the job immediately, and network with the top gurus in the industry. Plus, you may win a brand new Harley Davidson motorcycle at the prize drawing held in the exhibit hall.

DevConnections is held Oct 12 - 15 in Palm Springs at the beautiful La Quinta Resort and Club. Don't miss this opportunity to get the training you need to stay on top of today's technology and keep your competitive edge on the job. Register now online or call 800-438-6720 or 203-268-3204.

1. Developer .NET Perspectives

by Bill Sheldon, [email protected]

  • The Search for the Redirection Code
  • In "Understanding the Community Starter Kit's Source Code" (, I started to discuss the code that drives the Community Starter Kit, which is a free download from the Microsoft ASP.NET Web site ( In this column, I show you how this custom ASP.NET application redirects users to the communitydefault.aspx page, even though the client request calls for default.aspx. As you might imagine, this redirection ability is a powerful tool for ASP.NET developers.

    To understand how this internal redirection works, you need to examine the redirection code. However, you first have to find this code before you can examine it. Rather than just tell you the location in which the code resides, I'm going to walk you through a series of steps to describe how you might go about narrowing down the cause of this or other unrecognized behavior.

    The search for redirection code starts with communitydefault.aspx. An examination of this file reveals that it doesn't include any code that would cause the ASP.NET application to automatically redirect users to the file. This finding isn't surprising because the redirection has already occurred by the time this page appears. However, checking communitydefault.aspx is a good idea because the developers responsible for the kit might have included comments that explain the underlying architecture.

    The next file to check is global.asax because this file has handlers that are triggered during an application's key events (e.g., start-up, shutdown). A quick glance at the Community Starter Kit's global.asax file reveals that it has a custom module that the application calls during start-up. The module includes a timer, which calls a method that connects to a second community site or other Web service. The module also includes code that implements the appropriate interface to retrieve content from that other site or service. However, the various methods of global.asax aren't request-oriented but rather application- and session-oriented. Thus, the global.asax file isn't managing the redirection.

    The next place to check is the Community Starter Kit's web.config file. If you examine this configuration file, you'll notice an interesting structure that is, in part, self-describing XML. The section labeled configSections, which is at the top of the file, contains a series of sections. Each section maps to a portion of the .config file that defines the Community Starter Kit's settings. In the CommunityStarterKit section, you'll find a setting that provides a value for an attribute called BasePage. The presence of this attribute signals that the web.config file defines the name for the base page (i.e., primary page). However, how the application is getting the BasePage information is still a mystery.

    The final section in the web.config file is the System.Web section. This section contains standard application settings, such as authentication method and several other sections. The System.Web section also contains a subsection called httpModules. Although you might not immediately recognize it, this subsection is the key to automatic redirection.

    Before I discuss how the redirection works, you need to know how Microsoft IIS handles requests. As each request comes in, IIS parses the request and moves it through a series of steps. These steps include actions such as verifying user credentials if IIS manages the authentication and finding the appropriate file in response to a request for content. IIS doesn't perform these actions in a vacuum; rather, Internet Server API (ISAPI) interfaces help IIS. ISAPI interfaces can take two forms: extensions and filters.

    ISAPI extensions implement the logic to return a valid HTML stream from a URL that doesn't reference the standard HTML language. ASP and ASP.NET are two examples of ISAPI extensions.

    Of more interest to this discussion are ISAPI filters. Filters capture key events that occur with each request as the request passes through IIS. Filters are powerful but have several drawbacks. They're limited in their ability to work in the same context as, say, an ISAPI extension that handles a given request. More important, filters are low-level objects that are written in only C++.

    Fortunately, when Microsoft designed ASP.NET, it designed the IHttpModule interface. This interface provides the power of ISAPI filters but is implemented within the ASP.NET ISAPI extension. This implementation takes the form of HTTP modules, and the HTTP modules work in what's commonly called the ASP.NET pipeline. ASP.NET triggers the IHttpModule interface before the application handles the client request. The IHttpModule interface documentation is available at the following URL:

    The Community Starter Kit uses a custom HTTP module, which sets up the internal redirection to the correct page. Because HTTP modules work within the context of a request, the ASP.NET application can easily track the URL for the original request and, through IIS, respond with information based on that URL.

    The httpModules section of the Community Starter Kit's web.config file provides the following information:


    <add name="CommunitiesModule"
    ASPNET.StarterKit.Communities" />

    This information defines the class CommunitiesModule, which implements a custom HTTP module. The easiest way to locate the implementation for this class is to use Visual Studio .NET Enterprise Architect's (VSEA's) Class View to navigate to the class with this name. Alternatively, you can find this class in Solution Explorer by navigating to the Engine-Framework-BaseClasses folder.

    After you open the class's code, you'll find a function called Application_BeginRequest. This function handles the internal redirection of requests. Just as placing a breakpoint in InitPage lets you review how the Community Starter Kit builds pages, placing a breakpoint in Application_BeginRequest lets you see how the Community Starter Kit redirects each request.

    The IHttpModule interface is powerful--certainly every bit as powerful as the ISAPI filter interface. However, the IHttpModule interface is a much better choice for request manipulation because it lets you use a true Windows .NET Framework language and is part of the context of a request. An excellent reference that discusses the ASP.NET pipeline, HTTP modules, and the IHttpModule interface is at

    The ASP.NET Starter Kits are helpful because they demonstrate some well-engineered applications that you can examine to expand your knowledge of ASP.NET. So far, I've only discussed the plumbing of the Community Starter Kit. In my next column, I'll start to show you how to add, remove, and customize the various sections in this kit.

    Sponsor: New Exchange Event from Windows & .NET Magazine Connections

    Windows & .NET Magazine Connections will co-locate with the brand new Exchange Connections conference from Nov 2 - 5 in Orlando, FL. Register early and you'll receive access to both events for one price! Plus you'll save $300 if you register before the Early Bird Discount expires.

    Attendees to both events will have a chance to win a FREE 4 night/5 day Florida Vacation with airfare for two.

    Connections promises to deliver 100% pure technical content about cutting edge technology with real world solutions that you can use in your job today. To stay competitive, you need to invest your time to keep pace with the latest technology, tips, and tricks. Connections will give you the edge. Don't let this opportunity pass you by.

    Register today and you'll get:

    • Free one-year Windows & .NET Magazine subscription
    • Opportunity to win a FREE vacation plus other giveaways
    • Chance to mingle with the finest gathering of Windows gurus on the planet
    • $300 Registration discount
    Register online or call 1-800-505-1201 or 203-268-3204.

    2. Announcements
    (brought to you by Windows & .NET Magazine and its partners)

  • Get the eBook That Will Help You Get Certified!

  • The Insider's Guide to IT Certification, from the Windows & .NET Magazine Network, has one goal: to help you save time and money on your quest for certification. Find out how to choose the best study guides, save hundreds of dollars, and be successful as an IT professional. The amount of time you spend reading this book will be more than made up by the time you save preparing for your certification exams. Order your copy today!

  • Attention Visitors to Register Now for WinSummit 2003

  • WinSummit 2003 is the biggest European Windows Developers' Conference of the year. Featuring around 20 of the most known speakers delivering over 100 sessions and seminars. All the sessions are technical with a tutorial value. WinSummit is an event held by developers for developers. For further information and to register visit:

    3. Resource

  • Featured Thread: Trying to Create a Windows Service
  • Forum junior member VladaVlada is trying to create a Windows service that uses the onStart method to create and show icons on the system tray and the onStop method to remove icons. To join the discussion, go to the following URL:

    4. Events
    (brought to you by Windows & .NET Magazine)

  • New--Mobile & Wireless Road Show!
  • Learn more about the wireless and mobility solutions that are available today! Register now for this free event!

    5. New and Improved
    by Sue Cooper, [email protected]

  • Monitor Applications and Capture Problems
  • Identify Software announced AppSight Black Box, software for the Windows .NET Framework. This software pinpoints problems in .NET-based applications in production. You can deploy AppSight Black Box on all application tiers--inside the firewall as well as in remote locations--to record problem data. You can store the data in a central repository or save it as a highly compressed file, which you can email or attach to a trouble ticket. The software's analysis tools help pinpoint problems in performance, function, configuration, and user errors. AppSight Black Box supports Windows-based, .NET-based, and Java-based applications. Contact Identify Software at 919-878-3717, 800-364-5467, or [email protected]

    Sponsored Links

    FREE live trial-Backup & Disaster Recovery software w/ encryption;5945485;8214395;x?

    Free Download - NEW NetOp 7.6 - faster, more secure, remote support;5930423;8214395;j?

    6. Contact Us

  • About Developer .NET Perspectives -- [email protected]
  • About the newsletter -- [email protected]
  • About technical questions --
  • About product news -- [email protected]
  • About your subscription -- [email protected]
  • About sponsoring UPDATE -- [email protected]
  • This email newsletter is brought to you by Windows & .NET Magazine, the leading publication for IT professionals deploying Windows and related technologies. Subscribe today.

    Copyright 2003, Penton Media, Inc.

    Hide comments


    • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

    Plain text

    • No HTML tags allowed.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Lines and paragraphs break automatically.