SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom HttpModule which purpose is to check the presence of a specific cookie. If the cookie is not present, an error message should appear in place of the page.

The http module works as expected on application pages and classic pages. However, when I navigate to a Wiki page, it stops working.

Basically, the module subscribes to the Page_Init event of the page, when the request targets a page :

    public void Init(HttpApplication context)
        context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);

    private void context_PreRequestHandlerExecute(object sender, EventArgs e)
        HttpContext oContext = ((HttpApplication)sender).Context;

        var pageHandler = oContext.Handler as Page;
        if (pageHandler != null)
            pageHandler.Init += new EventHandler(Page_Init);
    private void Page_Init(object sender, EventArgs e)
                HttpContext.Current.Response.Write("<div align='center' ><font face='Verdana' size='2'><p><br/><br/>" + sMessage + "</p></font></div>");

When the target is a wiki page, pageHandler is of kind TemplateRedirectionPage. The init subscription is done.

But the subscribed method is never called in the case of a wiki page.

What can cause this difference ? how to remedy ?

[Edit] A bit of progress, I found with ILSpy this code of the TemplateRedirectPage class :

    public new void ProcessRequest(HttpContext context)
            IHttpHandlerFactory httpHandlerFactory = new TemplateRedirectionPage.DummyPageHandlerFactory();
            IHttpHandler handler = httpHandlerFactory.GetHandler(null, null, this.RedirectionUrl, null);
        catch (ThreadAbortException ex)
            // omitted for clarity

I'm betting this "transfert" cause the page_init to never be called, as the actual handler is no more the original page handler.

share|improve this question
I'm facing the same issue . Can you please let me know if you figured the problem – user3703305 Jun 13 '14 at 14:55
@user3703305, I'm sorry, but I don't remember the workaround... and I no more work for the customer who required this – Steve B Jun 16 '14 at 6:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.