© 2004 Microsoft Corporation. All rights reserved.

Figure 1 Get Base Type of Web Page
<%@ page language="C#" %>
<%
// finding out the base type of the web page
  string s;
  s = this.GetType().BaseType.ToString();

// Send some text out to the browser
  this.Response.Write("<html>");
  this.Response.Write("<body>");
  this.Response.Write(s);
  this.Response.Write("</body>");
  this.Response.Write("</html>");
%>
Figure 3 Using C# to Get Current Connection State
<%@ page language="C#" %>
<%
  string s;

  // Get The current context…
  HttpContext httpc = HttpContext.Current;

  // spit out some text…
  httpc.Response.Write("URL: ");

  // find out the URL of the current connection
  s = httpc.Request.RawUrl;
  httpc.Response.Output.WriteLine(s);
%>
Figure 4 Implementation of IHttpHandler in C#
using System.Web;

namespace MSDNHandlers {

   public class CSHandler : IHttpHandler {
    
      public void ProcessRequest(HttpContext context) {
         context.Response.Write("Hello World in C#!");
      }

      public bool IsReusable() {
            return true;
      } 
   }
}
Figure 5 A Request Handler Written in Visual Basic .NET
Imports System.Web

Namespace MSDNHandlers

   Public Class VBHandler : 
   Implements IHttpHandler
    
      Public Sub ProcessRequest(Context As HttpContext) 
         Implements IHttpHandler.ProcessRequest
            Context.Response.Write("This is Visual Basic!")
         End Sub

      Public Function IsReusable() As Boolean 
         Implements IHttpHandler.IsReusable
            Return true
         End Function

    End Class

End Namespace
Figure 6 Associating Handlers with Incoming Requests
<configuration>

   <httphandlers>
      <add verb="*" path="VBHandler.aspx" 
         type="MSDNHandlers.VBHandler,VBHandler" />
      <add verb="*" path="CSHandler.aspx" 
         type="MSDNHandlers.CSHandler,CSHandler" />
   </httphandlers> 

</configuration>