Error while running HTTP handler project

G

Guest

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
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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
 
K

Kevin Spencer

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.
 
G

Guest

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
 
K

Kevin Spencer

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top