Amit Das
I sometimes see ASP.NET apps that include ASHX files. What are ASHX files?
By Amit Das in ASP.NET on Jun 20 2007
  • Anil Kumar
    Nov, 2012 23

    .ashx files are web-handler files in asp.net programming and define IHttpHandler interface. Whenever an .ashx file is requested, ProcessRequest() method is invoked automatically. ProcessRequest() is a method where we do make changes according to our requirement. Handlers are used in URL routing, Image handling, binary data handling etc. as it support backward compatibility.

    • 0
  • Amit Das
    Jun, 2007 20

    ASHX files contain HTTP handlers-software modules that handle raw HTTP requests received by ASP.NET. The following code institutes a simple HTTP handler:

    <%@ WebHandler Language="C#" Class="Hello"%>

    using System.Web;

    public class Hello : IHttpHandler
    {
        public void ProcessRequest (HttpContext context)
        {
            string name = context.Request["Name"];
            context.Response.Write ("Hello, " name);
        }

        public bool IsReusable
        {
            get { return true; }
        }
    }

    If this code is placed in an ASHX file named Hello.ashx and requested using the URL http://.../hello.ashx?Name=Jeff, it returns "Hello, Jeff" in the HTTP response. ASHX files provide developers with a convenient way to deploy HTTP handlers without customizing CONFIG files or modifying the IIS metabase.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS