Custom handler gets web.config type load error

G

Guest

I'm trying to write a custom handler for .rtf files on our website.

Using the book "Essential ASP.Net C#" as a guide, I wrote the following and
compiled to a dll (assembly named "rtf_cl":


using System;
using System.Web;
using System.Web.SessionState;
using System.IO;

namespace rtf_cl
{
public class rtfProc : IHttpHandler
{

public void ProcessRequest(HttpContext ctx)
{
string path, fnam, basefnam;
int idx;

path = ctx.Request.PhysicalPath;
idx = path.LastIndexOf("\\");
fnam = "";
basefnam = "";
if (idx >= 0)
{
fnam = path.Substring(idx+1,
path.Length-idx-1);
basefnam = fnam.Substring(0,fnam.Length-4);
// future code here, yadda yadda
}
ctx.Response.Write("testing fnam=" + fnam + "basefnam=" + basefnam);


}


public bool IsReusable
{
get {return true; }
}
}
}


I compiled that to "rtf_cl.dll" and copied it into the bin dir of the test
web app.

I went into IIS on the test web and mapped the .rtf document extension to
aspnet_isapi.dll, and put the appropriate entry in the web.config file. When
I run the test web page, which tries to load an .rtf document, the following
error appears:
======================================
Configuration Error

Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify your configuration file appropriately.

Parser Error Message: Could not load type rtfProc from assembly rtf_cl.

Source Error:

Line 4: <system.web>
Line 5: <httpHandlers>
Line 6: <add verb="GET" path="*.rtf" type="rtfProc, rtf_cl" />
Line 7: </httpHandlers>
Line 8:

Source File: c:\inetpub\wwwroot\rtfproc\web.config Line: 6

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573
======================================


So, it claims to not be able to load the type from the assembly. I'm baffled.

Thanks for any assistance.

-- Frank Shofner
 
K

Karl

I think you forgot to specify the namespace...Try:

<add verb="GET" path="*.rtf" type="rtf_cl.rtfProc, rtf_cl" />

I hope those are just dummy names (readability is win!) ;)
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top