views:

203

answers:

2

I successfully added and configured HttpHandler in an Asp.Net WebApplication, but facing problems while trying to add same HttpHandler to Asp.Net WebSite. I have registered it in the web.config, am i missing something

This is the error I am getting

 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 'MyHandler'.

    Line 98:     </pages>
    Line 99:     <httpHandlers>
    Line 100:      <add verb="*" path="*.result" type="MyHandler"/>
    Line 101:      <remove verb="*" path="*.asmx"/>

Here is handler

public class MyHandler: IHttpHandler
{
    #region IHttpHandler Members

    public bool IsReusable
    {
        get { return true; }
    }

    public void ProcessRequest(HttpContext context)
    {
    }
    #endregion
}

NOTE: I have not made any request for the handler via url, it is just not letting me run application.

Thanks

A: 

Try using the fully-qualified type name in your type attribute, including the assembly name. Like this:

<add verb="*" path="*.result" type="Namespace.MyHandler,AssemblyName" />
Dan Herbert
+1  A: 

Edit: I missed the WebSite at first:

Put the .cs in App_code and use this:

<add verb="*" path="*.result" type="MyHandler, App_Code"/>
Nick Craver
In WepApplication it is loaded even without any path like it is in Engine.Handlers.MyHandler , but I have just added MyHandler in web.cinfig and it works
Asad Butt
@Asad - I re-read, missed the vital **WebSite**...try the new answer above, it should work for you.
Nick Craver
Thanks mate, it worked. Any thoughts, why is it not recognized out side App_Code folder. Why is this different for WebSite ?
Asad Butt
@Asad - Just because you don't know what the resulting dll name was...if you look under your framework folder under windows, then temporary internet files you can find it. Inside App_Code though, all the code there gets compiled into an App_Code.dll, so the assembly name is predictable and usable in the web.confg. It's different because all code in a Web Application goes into a single, specified DLL name, so that's predictable as well.
Nick Craver