Shivprasad Koirala
ASP.NET Interview question :- How do we write a HttpHandler ?
By Shivprasad Koirala in ASP.NET on Feb 26 2011
  • sarika jain
    Mar, 2011 1

    CustomHttp.test is the name of the file that launches the HTTPHandler.

    you need to type the CustomHttp.test filename at the end of the URL and press the enter to start the Custom HTTPHandler.

    • 0
  • sarika jain
    Mar, 2011 1

    First Create a class 


    public class CustomHandler:IHttpHandler
    {
    public bool IsReusable
    {
    get
    { return true; }
    }
    public void ProcessRequest(System.Web.HttpContext context)
    {
    HttpResponse response=context.response;
    Response.Write("<html><body><h2>Sample HTTP Handler</h2></body></html>");
    }

    Do this in web.config file
    <compilation debug="true"/>
    <authentication mode="Windows"/>
    <httpHandlers>
    <add verb="*" path="CustomHttp.test"  type="CustomHTTP.CustomHandler"/>
    </httpHandlers>

    • 0
  • Shivprasad Koirala
    Feb, 2011 26

    Answer:

    This is a simple a .NET Interview question .Its a two step process.

    First create a class which implements Ihttphandler
     

    public class clsHttpHandler : IHttpHandler
    {
        public bool IsReusable
        {
            get { return true; }
        }
        public void ProcessRequest(HttpContext context)
        {
           // Put implementation here.
        }
    }

    Step 2 make a entry in the web.config file.

    <httpHandlers>
    <add verb="*" path="*.gif" type="clsHttpHandler"/>
    </httpHandlers>


    You can view my top ASP.NET Interview questions and answers

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS