This is a mirror of official site: http://jasper-net.blogspot.com/

Creating an HttpHandler to handle request of your own extension

| Monday, January 3, 2011
I have already posted about http handler in details before some time here. Now let’s create an http handler which will handle my custom extension. For that we need to create a http handlers class which will implement Ihttphandler. As we are implementing IHttpHandler we need to implement one method called process request and another one is isReusable property. The process request function will handle all the request of my custom extension.

so Here is the code for my http handler class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace Experiement
{
  public class MyExtensionHandler:IHttpHandler
  {
      public MyExtensionHandler()
      {
          //Implement intialization here
      }
     
      bool IHttpHandler.IsReusable
      {
          get { return true; }
      }

      void IHttpHandler.ProcessRequest(HttpContext context)
      {
         string excuttablepath = context.Request.AppRelativeCurrentExecutionFilePath;

         if (excuttablepath.Contains("HelloWorld.dotnetjalps"))
         {
             Page page = new HelloWorld();
             page.AppRelativeVirtualPath = context.Request.AppRelativeCurrentExecutionFilePath;
             page.ProcessRequest(context);

         }
      }
  }
}

Here in above code you can see that in process request function I am getting current executable path and then I am processing that page. Now Lets create a page with extension .dotnetjalps and then we will process this page with above created http handler. so let’s create it.


Read more: DotNetJalps

Posted via email from .NET Info

0 comments: