Error while running HTTP handler project

Discussion in 'ASP .Net' started by =?Utf-8?B?cHJhZGVlcF9UUA==?=, Feb 28, 2007.

  1. 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="Customhandler.Handler,Handler" />
    </httpHandlers>

    following is the code in Handler.ashx file

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

    using System;
    using System.Web;
    namespace Customhandler
    {
    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;
    }
    }

    }
    }

    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="Customhandler.Handler,Handler" />

    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
     
    =?Utf-8?B?cHJhZGVlcF9UUA==?=, Feb 28, 2007
    #1
    1. Advertising

  2. On Feb 28, 6:14 am, pradeep_TP <>
    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="Customhandler.Handler,Handler" />
    > </httpHandlers>
    >
    > following is the code in Handler.ashx file
    >
    > <%@ WebHandler Language="C#" Class="Customhandler.Handler" %>
    >
    > using System;
    > using System.Web;
    > namespace Customhandler
    > {
    > 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;
    > }
    > }
    >
    > }
    >
    > }
    >
    > 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="Customhandler.Handler,Handler" />
    >
    > 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.dll)

    Or, create a new project as a Class Library and copy the code from
    Handler.ashx into cs and compille it into DLL
     
    Alexey Smirnov, Feb 28, 2007
    #2
    1. Advertising

  3. 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="Customhandler.Handler,Handler"

    Thanks
    pradeep

    "Alexey Smirnov" wrote:

    > On Feb 28, 6:14 am, pradeep_TP <>
    > 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="Customhandler.Handler,Handler" />
    > > </httpHandlers>
    > >
    > > following is the code in Handler.ashx file
    > >
    > > <%@ WebHandler Language="C#" Class="Customhandler.Handler" %>
    > >
    > > using System;
    > > using System.Web;
    > > namespace Customhandler
    > > {
    > > 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;
    > > }
    > > }
    > >
    > > }
    > >
    > > }
    > >
    > > 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="Customhandler.Handler,Handler" />
    > >
    > > 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.dll)
    >
    > Or, create a new project as a Class Library and copy the code from
    > Handler.ashx into cs and compille it into DLL
    >
    >
     
    =?Utf-8?B?cHJhZGVlcF9UUA==?=, Feb 28, 2007
    #3
  4. On Feb 28, 9:26 am, pradeep_TP <>
    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="Customhandler.Handler,Handler"


    It will look for Customhandler.Handler class and you don't have it...

    I've found an example, which looks very similar to your program.
    Please check
    http://www.eggheadcafe.com/articles/20030113.asp

    Hope it helps
     
    Alexey Smirnov, Feb 28, 2007
    #4
  5. 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.ClassName 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" <> wrote in message
    news:...
    > 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="Customhandler.Handler,Handler"
    >
    > Thanks
    > pradeep
    >
    > "Alexey Smirnov" wrote:
    >
    >> On Feb 28, 6:14 am, pradeep_TP <>
    >> 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="Customhandler.Handler,Handler"
    >> > />
    >> > </httpHandlers>
    >> >
    >> > following is the code in Handler.ashx file
    >> >
    >> > <%@ WebHandler Language="C#" Class="Customhandler.Handler" %>
    >> >
    >> > using System;
    >> > using System.Web;
    >> > namespace Customhandler
    >> > {
    >> > 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;
    >> > }
    >> > }
    >> >
    >> > }
    >> >
    >> > }
    >> >
    >> > 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="Customhandler.Handler,Handler" />
    >> >
    >> > 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.dll)
    >>
    >> Or, create a new project as a Class Library and copy the code from
    >> Handler.ashx into cs and compille it into DLL
    >>
    >>
     
    Kevin Spencer, Feb 28, 2007
    #5
  6. 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.ClassName 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" <> wrote in message
    > news:...
    > > 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="Customhandler.Handler,Handler"
    > >
    > > Thanks
    > > pradeep
    > >
    > > "Alexey Smirnov" wrote:
    > >
    > >> On Feb 28, 6:14 am, pradeep_TP <>
    > >> 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="Customhandler.Handler,Handler"
    > >> > />
    > >> > </httpHandlers>
    > >> >
    > >> > following is the code in Handler.ashx file
    > >> >
    > >> > <%@ WebHandler Language="C#" Class="Customhandler.Handler" %>
    > >> >
    > >> > using System;
    > >> > using System.Web;
    > >> > namespace Customhandler
    > >> > {
    > >> > 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;
    > >> > }
    > >> > }
    > >> >
    > >> > }
    > >> >
    > >> > }
    > >> >
    > >> > 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="Customhandler.Handler,Handler" />
    > >> >
    > >> > 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.dll)
    > >>
    > >> Or, create a new project as a Class Library and copy the code from
    > >> Handler.ashx into cs and compille it into DLL
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?cHJhZGVlcF9UUA==?=, Feb 28, 2007
    #6
  7. 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:
    http://www.miradyne.net

    "pradeep_TP" <> wrote in message
    news:...
    > 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.ClassName 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" <> wrote in message
    >> news:...
    >> > 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="Customhandler.Handler,Handler"
    >> >
    >> > Thanks
    >> > pradeep
    >> >
    >> > "Alexey Smirnov" wrote:
    >> >
    >> >> On Feb 28, 6:14 am, pradeep_TP <>
    >> >> 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="Customhandler.Handler,Handler"
    >> >> > />
    >> >> > </httpHandlers>
    >> >> >
    >> >> > following is the code in Handler.ashx file
    >> >> >
    >> >> > <%@ WebHandler Language="C#" Class="Customhandler.Handler" %>
    >> >> >
    >> >> > using System;
    >> >> > using System.Web;
    >> >> > namespace Customhandler
    >> >> > {
    >> >> > 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;
    >> >> > }
    >> >> > }
    >> >> >
    >> >> > }
    >> >> >
    >> >> > }
    >> >> >
    >> >> > 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="Customhandler.Handler,Handler"
    >> >> > />
    >> >> >
    >> >> > 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.dll)
    >> >>
    >> >> Or, create a new project as a Class Library and copy the code from
    >> >> Handler.ashx into cs and compille it into DLL
    >> >>
    >> >>

    >>
    >>
    >>
     
    Kevin Spencer, Mar 1, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ^CrazyCoder^
    Replies:
    3
    Views:
    7,316
    Terrence Benade
    Sep 15, 2003
  2. Claude seraphin
    Replies:
    12
    Views:
    2,517
    samundersingh1983
    Feb 15, 2014
  3. David
    Replies:
    1
    Views:
    519
    David
    Jul 19, 2004
  4. Patter
    Replies:
    1
    Views:
    1,496
    =?Utf-8?B?UmFodWwgU29uaQ==?=
    Dec 1, 2005
  5. neal
    Replies:
    0
    Views:
    118
Loading...

Share This Page