Results 1 to 6 of 6

Thread: ASP.NET HTTP Handler

  1. #1
    Join Date
    Nov 2009
    Posts
    1,340

    ASP.NET HTTP Handler

    Hello, I want to know the details of the HTTP Handler From the ASP.NET. I have tried to search the details about it on internet, but it is quiet complicated to get the details about it. If you are having information about it in simple words then please provide that to me. I want to know the details about it.

  2. #2
    Preator Guest

    Re: ASP.NET HTTP Handler

    All requests made to an ASP.NET application are managed by a specialized component: the HTTP handler. The best known is the manager page, it processes the requests made to the ASPX pages, creates the page objects, executes the code and return the final html. You can create your own HttpHandler to handle specific requests. It can be for example to display images that need pre-treatment (loading from a database, resizing, etc ...)

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: ASP.NET HTTP Handler

    Hello, you can simply compile the HTTP handler by the use of the steps below:
    1. Open Microsoft Visual Studio .NET. In Visual C# .NET, create a new Class Library project named MyHandler.
    2. Set a reference to the System.Web.dll assembly.
    3. Add the following directive to the class:
      Code:
            using System.Web;
    4. Rename the class SyncHandler.cs, and then change the class definition to reflect this.
    5. Implement the IHttpHandler interface. Your class definition should appear as follows:
      Code:
           public class SyncHandler : IHttpHandler
    6. Implement the IsReusable property and the ProcessRequest method of the IHttpHandler interface. Because this is a synchronous handler, return False for the IsReusable property so that the handler is not pooled.
      Code:
            public bool IsReusable
            {
               get {return false;}
            }
      
            public void ProcessRequest(HttpContext context)
            {
               context.Response.Write("Hello from custom handler.");
            }
    7. Compile the project.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: ASP.NET HTTP Handler

    Http module contains the following events:
    • BeginRequest
    • AuthenticateRequest
    • AuthorizeRequest
    • ResolveRequestCache
    • AcquireRequestState
    • PreRequestHandlerExecute
    • PostRequestHandlerExecute
    • ReleaseRequestState
    • UpdateRequestCache
    • EndRequest
    • PreSendRequestHeaders
    • PreSendRequestContent

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: ASP.NET HTTP Handler

    If you look at the configuration section handler then you will come to know that it is used for the mapping of the URLs which are approaching towards you from the IHttpHandler or IHttpHandlerFactory class. You will able to declare them at different levels such as at the computer level or you can declare it at the site level or you can use it at the application level.
    By simply using tag directives administrator can simly configure this section. For that you just need to use the following syntax:

    Code:
    <httpHandlers>
       <add verb="[verb list]" path="[path]" type="[COM+ Class], [Assembly]" validate="[true/false]" />
       <remove verb="[verb list]" path="[path]" />
       <clear />
    </httpHandlers>

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    Re: ASP.NET HTTP Handler

    Hello, I have the code below which will help you for creating a code for the custom HTTP Handler. So, just make use of it and solve the problem of yours.
    Code:
    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Web;
     
    public class HttpHandlerTesting : IHttpHandler {
        
        public void RequestProcessing (HttpContext Hcontext) 
        {
    Hcontext.Response.ContentType = "image/png";
          string str = Hcontext.Request.QueryString["str"];
          int height = Convert.ToInt32(Hcontext.Request.QueryString["height"]);
          int width = Convert.ToInt32(Hcontext.Request.QueryString["width"]);
          Bitmap bitmap;
    Color color = Color.FromArgb(255, 253, 244);
          MemoryStream memoryStream = new MemoryStream();
     
          switch (str)
          {
                default:
                  int pt = 1;
                  while (Hcontext.Request.QueryString["P" + pt.ToString()] != null)
                      pt++;
                  decimal[] vals = new Decimal[pt];
                  for (int i = 0; i < pt; i++)
                        vals[i] = Convert.ToInt32(
                     Hcontext.Request.QueryString["P" + i.ToString()]);
     
                  PieChart pichart = new PieChart();
                  bitmap = pichart.Draw(color, width, height, vals);
                  break;
            }
            bitmap.Save(memoryStream, ImageFormat.Png);
            memoryStream.WriteTo(Hcontext.Response.OutputStream);
        }
         public bool IsReusable 
        {
            get {
                return false;
            }
        } 
    }
    public class PieChart
    {
        public Bitmap Draw(Color color, int width, int height, decimal[] vals)
        {   
            Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage(bitmap);
            SolidBrush sdbrush = new SolidBrush(color);
            g.FillRectangle(sdbrush, 0, 0, width, height);
            sdbrush.Dispose(); 
            SolidBrush[] sdbrush = new SolidBrush[10];
            sdbrush[0] = new SolidBrush(Color.Yellow);
            sdbrush[1] = new SolidBrush(Color.Green);
            sdbrush[2] = new SolidBrush(Color.Blue);
            sdbrush[3] = new SolidBrush(Color.Cyan);
            sdbrush[4] = new SolidBrush(Color.Magenta);
            sdbrush[5] = new SolidBrush(Color.Red);
            sdbrush[6] = new SolidBrush(Color.Black);
            sdbrush[7] = new SolidBrush(Color.Gray);
            sdbrush[8] = new SolidBrush(Color.Maroon);
            sdbrush[9] = new SolidBrush(Color.LightBlue);
            decimal total = 0.0m;
            foreach (decimal val in vals)
                total += val;
             float first = 0.0f;
            float last = 0.0f;
            decimal curr = 0.0m;
            for (int i = 0; i < vals.Length; i++)
            {
                curr += vals[i];
                first = last;
                last = (float)(curr / total) * 360.0f;
                g.FillPie(sdbrush[i % 10], 0.0f, 0.0f, width,
                                 height, first, last - first);
            }
            foreach (SolidBrush cleanBrush in sdbrush)
                cleanBrush.Dispose();
             return bitmap;
        }
    }

Similar Threads

  1. How to fix HTTP error 307 Temporary Redirect (since HTTP/1.1)?
    By Charu Sharma in forum Networking & Security
    Replies: 6
    Last Post: 05-04-2012, 01:14 AM
  2. The event handler in WSS 3.0
    By Computer_Freak in forum Tips & Tweaks
    Replies: 2
    Last Post: 21-02-2011, 07:05 AM
  3. Error in the PDF Preview Handler
    By aSITA in forum Windows Software
    Replies: 4
    Last Post: 24-01-2011, 12:46 AM
  4. HTTP: 12029 no HTTP access for IE
    By Captainlumpy in forum Windows XP Support
    Replies: 5
    Last Post: 29-07-2010, 06:43 AM
  5. How to add an AutoPlay Handler for an Event ?
    By Dyumani in forum Operating Systems
    Replies: 3
    Last Post: 17-03-2009, 11:29 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,718,722,723.23617 seconds with 17 queries