Error while running HTTP handler project

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?cHJhZGVlcF9UUA==?=

    Error while running HTTP handler project

    I am trying to create a simple HTTP handler in ASP.net 2.0. I am using VS
    2005. I am trying to handle a custom extension file givein in the URL. I
    have also created the following entry in the web.config file

    <httpHandlers >
    <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler" />
    </httpHandlers>

    following is the code in Handler.ashx file

    <%@ WebHandler Language="C#" Class="Customha ndler.Handler" %>

    using System;
    using System.Web;
    namespace Customhandler
    {
    public class Handler : IHttpHandler
    {

    public void ProcessRequest( HttpContext context)
    {
    context.Respons e.ContentType = "text/plain";
    context.Respons e.Write("Hello World");
    }

    public bool IsReusable
    {
    get
    {
    return false;
    }
    }

    }
    }

    During compliation there is no error..but when I run the code, I get the
    following error

    Could not load file or assembly 'Handler' or one of its dependencies. The
    system cannot find the file specified

    the following line from the web.confg file is highlighted in RED

    <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler" />

    I can understand that it is looking for handler.dll file. But I do not see
    any DLL file beign createdin VS 2005. I am a little new to VS 2005. Does
    anyone know how to resolve this problem

    many thanks :)
    pradeep_tp
  • Alexey Smirnov

    #2
    Re: Error while running HTTP handler project

    On Feb 28, 6:14 am, pradeep_TP <pradee...@disc ussions.microso ft.com>
    wrote:
    I am trying to create a simple HTTP handler in ASP.net 2.0. I am using VS
    2005. I am trying to handle a custom extension file givein in the URL. I
    have also created the following entry in the web.config file
    >
    <httpHandlers >
    <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler" />
    </httpHandlers>
    >
    following is the code in Handler.ashx file
    >
    <%@ WebHandler Language="C#" Class="Customha ndler.Handler" %>
    >
    using System;
    using System.Web;
    namespace Customhandler
    {
    public class Handler : IHttpHandler
    {
    >
    public void ProcessRequest( HttpContext context)
    {
    context.Respons e.ContentType = "text/plain";
    context.Respons e.Write("Hello World");
    }
    >
    public bool IsReusable
    {
    get
    {
    return false;
    }
    }
    >
    }
    >
    }
    >
    During compliation there is no error..but when I run the code, I get the
    following error
    >
    Could not load file or assembly 'Handler' or one of its dependencies. The
    system cannot find the file specified
    >
    the following line from the web.confg file is highlighted in RED
    >
    <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler" />
    >
    I can understand that it is looking for handler.dll file. But I do not see
    any DLL file beign createdin VS 2005. I am a little new to VS 2005. Does
    anyone know how to resolve this problem
    >
    many thanks :)
    pradeep_tp
    you have to call it as http://localhost/Handler.ashx

    So, delete "add verb path" from web.config and try again...

    IIS mappings for ashx is exist by default (to aspnet_isapi.dl l)

    Or, create a new project as a Class Library and copy the code from
    Handler.ashx into cs and compille it into DLL

    Comment

    • =?Utf-8?B?cHJhZGVlcF9UUA==?=

      #3
      Re: Error while running HTTP handler project

      Hi Alexy,

      The following tag in web.config file points to .imgw type of file and not
      ashx file. I am simply trying to invoke my handler when a user refers to a
      file with extension .imgw.

      Your solution of creating a class library file will work for me, but I want
      to understand why it is not working in this case. I do not get any such
      errors while creating HTTP module.

      <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler"

      Thanks
      pradeep

      "Alexey Smirnov" wrote:
      On Feb 28, 6:14 am, pradeep_TP <pradee...@disc ussions.microso ft.com>
      wrote:
      I am trying to create a simple HTTP handler in ASP.net 2.0. I am using VS
      2005. I am trying to handle a custom extension file givein in the URL. I
      have also created the following entry in the web.config file

      <httpHandlers >
      <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler" />
      </httpHandlers>

      following is the code in Handler.ashx file

      <%@ WebHandler Language="C#" Class="Customha ndler.Handler" %>

      using System;
      using System.Web;
      namespace Customhandler
      {
      public class Handler : IHttpHandler
      {

      public void ProcessRequest( HttpContext context)
      {
      context.Respons e.ContentType = "text/plain";
      context.Respons e.Write("Hello World");
      }

      public bool IsReusable
      {
      get
      {
      return false;
      }
      }

      }

      }

      During compliation there is no error..but when I run the code, I get the
      following error

      Could not load file or assembly 'Handler' or one of its dependencies. The
      system cannot find the file specified

      the following line from the web.confg file is highlighted in RED

      <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler" />

      I can understand that it is looking for handler.dll file. But I do not see
      any DLL file beign createdin VS 2005. I am a little new to VS 2005. Does
      anyone know how to resolve this problem

      many thanks :)
      pradeep_tp
      >
      you have to call it as http://localhost/Handler.ashx
      >
      So, delete "add verb path" from web.config and try again...
      >
      IIS mappings for ashx is exist by default (to aspnet_isapi.dl l)
      >
      Or, create a new project as a Class Library and copy the code from
      Handler.ashx into cs and compille it into DLL
      >
      >

      Comment

      • Alexey Smirnov

        #4
        Re: Error while running HTTP handler project

        On Feb 28, 9:26 am, pradeep_TP <pradee...@disc ussions.microso ft.com>
        wrote:
        Hi Alexy,
        >
        The following tag in web.config file points to .imgw type of file and not
        ashx file. I am simply trying to invoke my handler when a user refers to a
        file with extension .imgw.
        A refer in the web.config is not enough. You need to map *.imgw in IIS
        too.

        <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler"
        It will look for Customhandler.H andler class and you don't have it...

        I've found an example, which looks very similar to your program.
        Please check


        Hope it helps

        Comment

        • Kevin Spencer

          #5
          Re: Error while running HTTP handler project

          First, an HttpHandler should exist in a .Net class library (.dll) in your
          bin folder. Second, the dll is referenced in the web.config file, first, by
          the Namespace.Class Name and then by the dll file name (without the .dll
          extension). Finally, the IIS web site must be configured to hand off
          requests for resources with the extension referenced in the web.config file
          to the ASP.Net ISAPI, just as it has for other file extensions. This can be
          found in the Web Site Properties dialog box, under the Home Directory tab,
          and the Configuration button, if using IIS 5 or IIS 6.

          --
          HTH,

          Kevin Spencer
          Microsoft MVP
          Software Composer
          Thoughts and Ideas about programming, philosophy, science, arts, life, God, and related subjects.


          I had the same problem once. Fixed it using the same solution.

          "pradeep_TP " <pradeepTP@disc ussions.microso ft.comwrote in message
          news:7B4EC116-EBE1-4163-8C2D-2BFFC36DFFBA@mi crosoft.com...
          Hi Alexy,
          >
          The following tag in web.config file points to .imgw type of file and not
          ashx file. I am simply trying to invoke my handler when a user refers to a
          file with extension .imgw.
          >
          Your solution of creating a class library file will work for me, but I
          want
          to understand why it is not working in this case. I do not get any such
          errors while creating HTTP module.
          >
          <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler"
          >
          Thanks
          pradeep
          >
          "Alexey Smirnov" wrote:
          >
          >On Feb 28, 6:14 am, pradeep_TP <pradee...@disc ussions.microso ft.com>
          >wrote:
          I am trying to create a simple HTTP handler in ASP.net 2.0. I am using
          VS
          2005. I am trying to handle a custom extension file givein in the URL.
          I
          have also created the following entry in the web.config file
          >
          <httpHandlers >
          <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler"
          />
          </httpHandlers>
          >
          following is the code in Handler.ashx file
          >
          <%@ WebHandler Language="C#" Class="Customha ndler.Handler" %>
          >
          using System;
          using System.Web;
          namespace Customhandler
          {
          public class Handler : IHttpHandler
          {
          >
          public void ProcessRequest( HttpContext context)
          {
          context.Respons e.ContentType = "text/plain";
          context.Respons e.Write("Hello World");
          }
          >
          public bool IsReusable
          {
          get
          {
          return false;
          }
          }
          >
          }
          >
          }
          >
          During compliation there is no error..but when I run the code, I get
          the
          following error
          >
          Could not load file or assembly 'Handler' or one of its dependencies.
          The
          system cannot find the file specified
          >
          the following line from the web.confg file is highlighted in RED
          >
          <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler" />
          >
          I can understand that it is looking for handler.dll file. But I do not
          see
          any DLL file beign createdin VS 2005. I am a little new to VS 2005.
          Does
          anyone know how to resolve this problem
          >
          many thanks :)
          pradeep_tp
          >>
          >you have to call it as http://localhost/Handler.ashx
          >>
          >So, delete "add verb path" from web.config and try again...
          >>
          >IIS mappings for ashx is exist by default (to aspnet_isapi.dl l)
          >>
          >Or, create a new project as a Class Library and copy the code from
          >Handler.ashx into cs and compille it into DLL
          >>
          >>

          Comment

          • =?Utf-8?B?cHJhZGVlcF9UUA==?=

            #6
            Re: Error while running HTTP handler project

            HI Kevin,

            I had already registered the extension *.imgw. Sorry i forgot to mention in
            post. I agree with what you are saying about presense of DLL fine in BIN
            folder, but VS 2005 doesnt create a BIN folder. I am a little new to VS
            2005.Can you please tell me how to create a DLL file without creatinga setup
            project.

            Regards
            Pradeep

            "Kevin Spencer" wrote:
            First, an HttpHandler should exist in a .Net class library (.dll) in your
            bin folder. Second, the dll is referenced in the web.config file, first, by
            the Namespace.Class Name and then by the dll file name (without the .dll
            extension). Finally, the IIS web site must be configured to hand off
            requests for resources with the extension referenced in the web.config file
            to the ASP.Net ISAPI, just as it has for other file extensions. This can be
            found in the Web Site Properties dialog box, under the Home Directory tab,
            and the Configuration button, if using IIS 5 or IIS 6.
            >
            --
            HTH,
            >
            Kevin Spencer
            Microsoft MVP
            Software Composer
            Thoughts and Ideas about programming, philosophy, science, arts, life, God, and related subjects.

            >
            I had the same problem once. Fixed it using the same solution.
            >
            "pradeep_TP " <pradeepTP@disc ussions.microso ft.comwrote in message
            news:7B4EC116-EBE1-4163-8C2D-2BFFC36DFFBA@mi crosoft.com...
            Hi Alexy,

            The following tag in web.config file points to .imgw type of file and not
            ashx file. I am simply trying to invoke my handler when a user refers to a
            file with extension .imgw.

            Your solution of creating a class library file will work for me, but I
            want
            to understand why it is not working in this case. I do not get any such
            errors while creating HTTP module.

            <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler"

            Thanks
            pradeep

            "Alexey Smirnov" wrote:
            On Feb 28, 6:14 am, pradeep_TP <pradee...@disc ussions.microso ft.com>
            wrote:
            I am trying to create a simple HTTP handler in ASP.net 2.0. I am using
            VS
            2005. I am trying to handle a custom extension file givein in the URL.
            I
            have also created the following entry in the web.config file

            <httpHandlers >
            <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler"
            />
            </httpHandlers>

            following is the code in Handler.ashx file

            <%@ WebHandler Language="C#" Class="Customha ndler.Handler" %>

            using System;
            using System.Web;
            namespace Customhandler
            {
            public class Handler : IHttpHandler
            {

            public void ProcessRequest( HttpContext context)
            {
            context.Respons e.ContentType = "text/plain";
            context.Respons e.Write("Hello World");
            }

            public bool IsReusable
            {
            get
            {
            return false;
            }
            }

            }

            }

            During compliation there is no error..but when I run the code, I get
            the
            following error

            Could not load file or assembly 'Handler' or one of its dependencies.
            The
            system cannot find the file specified

            the following line from the web.confg file is highlighted in RED

            <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler" />

            I can understand that it is looking for handler.dll file. But I do not
            see
            any DLL file beign createdin VS 2005. I am a little new to VS 2005.
            Does
            anyone know how to resolve this problem

            many thanks :)
            pradeep_tp
            >
            you have to call it as http://localhost/Handler.ashx
            >
            So, delete "add verb path" from web.config and try again...
            >
            IIS mappings for ashx is exist by default (to aspnet_isapi.dl l)
            >
            Or, create a new project as a Class Library and copy the code from
            Handler.ashx into cs and compille it into DLL
            >
            >
            >
            >
            >

            Comment

            • Kevin Spencer

              #7
              Re: Error while running HTTP handler project

              You create a DLL by creating a Class Library project, and adding it to your
              Solution. The reference the Class Library project in the ASP.Net project.

              --
              HTH,

              Kevin Spencer
              Microsoft MVP

              Help test our new betas,
              DSI PrintManager, Miradyne Component Libraries:


              "pradeep_TP " <pradeepTP@disc ussions.microso ft.comwrote in message
              news:2262D323-54A5-43FA-9D14-7C74758074EB@mi crosoft.com...
              HI Kevin,
              >
              I had already registered the extension *.imgw. Sorry i forgot to mention
              in
              post. I agree with what you are saying about presense of DLL fine in BIN
              folder, but VS 2005 doesnt create a BIN folder. I am a little new to VS
              2005.Can you please tell me how to create a DLL file without creatinga
              setup
              project.
              >
              Regards
              Pradeep
              >
              "Kevin Spencer" wrote:
              >
              >First, an HttpHandler should exist in a .Net class library (.dll) in your
              >bin folder. Second, the dll is referenced in the web.config file, first,
              >by
              >the Namespace.Class Name and then by the dll file name (without the .dll
              >extension). Finally, the IIS web site must be configured to hand off
              >requests for resources with the extension referenced in the web.config
              >file
              >to the ASP.Net ISAPI, just as it has for other file extensions. This can
              >be
              >found in the Web Site Properties dialog box, under the Home Directory
              >tab,
              >and the Configuration button, if using IIS 5 or IIS 6.
              >>
              >--
              >HTH,
              >>
              >Kevin Spencer
              >Microsoft MVP
              >Software Composer
              >http://unclechutney.blogspot.com
              >>
              >I had the same problem once. Fixed it using the same solution.
              >>
              >"pradeep_TP " <pradeepTP@disc ussions.microso ft.comwrote in message
              >news:7B4EC11 6-EBE1-4163-8C2D-2BFFC36DFFBA@mi crosoft.com...
              Hi Alexy,
              >
              The following tag in web.config file points to .imgw type of file and
              not
              ashx file. I am simply trying to invoke my handler when a user refers
              to a
              file with extension .imgw.
              >
              Your solution of creating a class library file will work for me, but I
              want
              to understand why it is not working in this case. I do not get any such
              errors while creating HTTP module.
              >
              <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler"
              >
              Thanks
              pradeep
              >
              "Alexey Smirnov" wrote:
              >
              >On Feb 28, 6:14 am, pradeep_TP <pradee...@disc ussions.microso ft.com>
              >wrote:
              I am trying to create a simple HTTP handler in ASP.net 2.0. I am
              using
              VS
              2005. I am trying to handle a custom extension file givein in the
              URL.
              I
              have also created the following entry in the web.config file
              >
              <httpHandlers >
              <add verb="*" path="*.imgw"
              type="Customhan dler.Handler,Ha ndler"
              />
              </httpHandlers>
              >
              following is the code in Handler.ashx file
              >
              <%@ WebHandler Language="C#" Class="Customha ndler.Handler" %>
              >
              using System;
              using System.Web;
              namespace Customhandler
              {
              public class Handler : IHttpHandler
              {
              >
              public void ProcessRequest( HttpContext context)
              {
              context.Respons e.ContentType = "text/plain";
              context.Respons e.Write("Hello World");
              }
              >
              public bool IsReusable
              {
              get
              {
              return false;
              }
              }
              >
              }
              >
              }
              >
              During compliation there is no error..but when I run the code, I get
              the
              following error
              >
              Could not load file or assembly 'Handler' or one of its
              dependencies.
              The
              system cannot find the file specified
              >
              the following line from the web.confg file is highlighted in RED
              >
              <add verb="*" path="*.imgw" type="Customhan dler.Handler,Ha ndler"
              />
              >
              I can understand that it is looking for handler.dll file. But I do
              not
              see
              any DLL file beign createdin VS 2005. I am a little new to VS 2005.
              Does
              anyone know how to resolve this problem
              >
              many thanks :)
              pradeep_tp
              >>
              >you have to call it as http://localhost/Handler.ashx
              >>
              >So, delete "add verb path" from web.config and try again...
              >>
              >IIS mappings for ashx is exist by default (to aspnet_isapi.dl l)
              >>
              >Or, create a new project as a Class Library and copy the code from
              >Handler.ashx into cs and compille it into DLL
              >>
              >>
              >>
              >>
              >>

              Comment

              Working...