locked
How to use HTTPHandler RRS feed

  • Question

  • User583282017 posted

    Dear, Can you please tell me how can i use HTTPHandler in my application , i am just creating for testing it but i am confused in that if i have to register it in Isapi_dll,what i am doing currently is,

    i am writing this code in a class file,

    public class ImgHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
           //if (context.Request.RawUrl.Contains("Home.aspx"))
           // {
           //     context.Response.Redirect("abc.html");
           // }
            context.Response.Write("Hello From Handler");
        }
    
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

    and this code in web.config file,

    <add name="MyImageHandler" verb="*" path="*.aspx" type="WebApp.ImgHandler"/>

    Please suggest me if i am doing anything wrong.

    Wednesday, October 29, 2014 5:09 AM

Answers

All replies

  • User-821857111 posted

    Gaurav Balyan

    i am confused in that if i have to register it in Isapi_dll

    No you don't.

    If you use a Generic Handler (ashx file) you don't even need to add an entry in web.config.

    For more information, see this:  HTTP Handlers and HTTP Modules Overview

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 29, 2014 5:13 AM
  • User1636150863 posted

    Hi,

    Try Changing following

    <add name="MyImageHandler" verb="*" path="*.aspx" type="ImgHandler"/>

    Also following article will be usefull for you,

    http://www.codeproject.com/Articles/335968/Implementing-HTTPHandler-and-HTTPModule-in-ASP-NET

    Regards,

    Ajay

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 29, 2014 5:23 AM
  • User583282017 posted

    I tried the link but after adding the line,

    <add verb="*" path="*.cspx" type="CspxHandler"/>

    i am getting the error this page cannot be displayed.

    Wednesday, October 29, 2014 5:30 AM
  • User-821857111 posted

    path="*.cspx"

    You need to register that. It's a custom handler. Check the article I linked to.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 29, 2014 5:35 AM