Custom HTTP-handlers do not work (HTTP 404 Not Found)

Klotos Live asked on March 11, 2014 04:16


I'm developing a plugin for the Kentico CMS 7. I had downloaded trial version of Kentico 7.0 (KenticoCMS_7_0.exe) from your site in the previous week. I installed it as a web-application; installation was successful, all works fine, I use "localhost" domain in order to use 30-day trial without limitations. I use only one sample site - "Intranet Portal".

My plugin requires using a lot of HTTP-handlers (implementation of IHttpHandler interface). I have a distinct assembly (class library, DLL) with already defined HTTP-handlers and I must use them in the plugin. I successfully added this DLL to the Kentico project in Visual Studio, stated all paths to the HTTP-handlers in the web.config and ... nothing works.

I tried to use both IIS 7.5 (Windows 7) and ASP.NET Development Server, Classinc and Integrated pipeline in the IIS - in all cases my requests to the HTTP-handlers have a "HTTP 404 Not Found" response. Then I decided to write my own custom test HTTP-handler in the Kentico project:

namespace CMSApp.GDViewer
    public class MyHttpHandler : IHttpHandler
        /// <summary>
        /// </summary>
        public bool IsReusable
        { get { return true; } }

        public void ProcessRequest(HttpContext context)
            context.Response.ContentType = "next/plain";
            context.Response.Write("Just simple and test text response");

And web.config inclusion: <add name="MyHttpHandler" verb="GET" path="myhttphandler" type="CMSApp.GDViewer.MyHttpHandler"/>

Nothing helps - only 404. Then I had created new HTTP-handler "MyHttpHandler2" with the same code, but not as a ".cs" file, but as a ".ashx" and without path inclusion in the web.config. And yes, when requesting its full path - "http://localhost/GDViewer/myHttphandler2" - it works fine.

Then I had found the next thing. When IIS returns "HTTP 404.0 - Not Found" when requesting HTTP-handlers, it also returns additional information, with next:

Module: CMSApplicationModule
Error code:0x00000000

"CMSApplicationModule". Hmm. I had found tis HTTP-module in the web.config <add name="CMSApplicationModule" preCondition="managedHandler" type="CMS.CMSHelper.CMSApplicationModule, CMS.CMSHelper" />

and deleted/commented it. And voila - all my HTTP-handlers, both developed by myself in this project and located in the external DLL - work successfully. All paths to the HTTP-handlers are valid.

But the main site - not.

Server Error in '/' Application.

[SystemMethods]: System events are not initialized. You must call CMSContext.Init() before running any of your methods. In web application, the web.config file must contain registration for the CMSApplicationModule: <add name="CMSApplicationModule" type="CMS.CMSHelper.CMSApplicationModule, CMS.CMSHelper"/>

So, my question is the next. How to use my own HTTP-handlers with paths defined in the web.config in the Kentico project? When disabling "CMSApplicationModule" all HTTP-handlers work fine, but the site itself - not. What to do? Please help, answer to this question is vital for me.


Correct Answer

Brenden Kehren answered on March 11, 2014 06:30

Change your web.config back to the way it was and exclude the /GDViewer directory from Kentico processing in Site Manager/Settings>URLs and SEO>URL Format>Excluded URLs. You also might read up on the import/export folders and where and how to place custom files on your site.

2 votesVote for this answer Unmark Correct answer

Recent Answers

Klotos Live answered on March 11, 2014 10:49

Your answer has solved my problem. Thank you very much!

0 votesVote for this answer Mark as a Correct answer

Mohammed Habeeb answered on April 3, 2014 09:16

The issue is common is IIS 7 and it depends on the Pipeline mode the Application pool is configured. According to this, the handler configuration section will change.

It's explained in this post:

It works for me. It says for Classic mode use:

<system.web> </system.web>

and integrated pipeline mode use

<system.webServer> <system.webServer>

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.