Saturday, 22 March 2014

what is HTTP handler in ?

1.       It is different from HTTP modules not only because of their position in the request- processing pipe line but also because they must be mapped to a specific file extension.

2.       HTTP handlers are the last stop for incoming HTTP Request and are ultimately the point in the request processing pipeline and as responsible to create response.

3.       Generic Handlers: There is generic Handlers file type is providing. Adding this generic handlers to the project with ashx file extensions. The ashx is unique file extensions. It is provided by ASP.Net otherwise we need to add it manually;

4.       Add the Generic Handler file to the project, it add the file with an .ashx extension. The .ashx file extension is the defaut HTTPHandler file extension file extension setup by ASP.Net.

5.       Code snippet  that implements the IHTTPHandler Interface, which require the ProcessRequest method and IsResuable property. The class stub changes the content type to plain and then writes the “Hello World” string to the output stream. The IsReusable  property simply lets ASP.Net know if coming HTTP requests can reuse the sample instance of this HttpHandler.

<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World");
    public bool IsReusable {
        get {
            return false;

No comments:

Post a Comment