http handler

Matei Beloiu asked on June 18, 2016 00:21

I am using KTCO 8.2. I am trying to implement a basic http handler, but when I try to integrate it into kentico, the CMSApplicationModule is blocking it somehow. here is what my web.config file looks like:

    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
      <remove name="XHtmlModule" />
      <remove name="CMSApplicationModule" />
      <remove name="UrlRoutingModule-4.0" />
      <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" />
      <add name="XHtmlModule" type="CMS.OutputFilter.OutputFilterModule, CMS.OutputFilter" />
      <add name="CMSApplicationModule" preCondition="managedHandler" type="CMS.Base.ApplicationModule, CMS.Base" />
      <remove name="WebDAV" />
      <remove name="MetaWeblogAPI" />
      <remove name="ChartImageHandler" />
      <add name="HelloWorldHandler" path="*.sample" verb="*" type="CMS.Base.DefaultHttpHandler" resourceType="Unspecified" requireAccess="None" preCondition="integratedMode" /> 

       Basic http handler:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// Summary description for HelloWorldHandler
    /// </summary>
    public class HelloWorldHandler : IHttpHandler
        public HelloWorldHandler()
        public void ProcessRequest(HttpContext context)
            HttpRequest Request = context.Request;
            HttpResponse Response = context.Response;
            // This handler is called whenever a file ending 
            // in .sample is requested. A file with that extension
            // does not need to exist.
        public bool IsReusable
            // To enable pooling, return true here.
            // This keeps the handler in memory.
            get { return false; }

Recent Answers

Anton Grekhovodov answered on June 19, 2016 17:07

Hi Matei,

You should wrap your http handler class into namespace and then use in web.config the next type attribute type="[namespace or root namespace].HelloWorldHandler"

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on June 20, 2016 16:48

What is that you're trying to reach? Have you looked at Kentico global events? - They are useful in most of the cases.

1 votesVote for this answer Mark as a Correct answer

Matei Beloiu answered on June 30, 2016 17:29

The issue was that I had a "Page not found URL" configured in the content settings. This setting prevents from hitting the handler settings in web.config. After removing the url, the handler settings are being applied and it works.

Kentico should not block access to web.config if a url does not exist, because it might very well be a handler. It should redirect after it has established that the url provided is not a handler...allowing access to web.config prior to redirection.

0 votesVote for this answer Mark as a Correct answer

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