Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Elwyn 8 posts 28 karma points
    Apr 14, 2011 @ 03:42
    Elwyn
    0

    Custom umbracoRequestModule not being used on staging site

    Hi y'all

    I have a custom umbracoRequestModule, which I placed in the umbraco.presentation namespace.

    namespace umbraco.presentation
    {
        public class requestModuleOverride : requestModule
        {
            public requestModuleOverride() : base()
            {
            }
    
            //... my custom methods here
        }
    }

    I modified my web.config to use this new class:

    <add name="umbracoRequestModule" type="umbraco.presentation.requestModuleOverride" />
    

     

    Later, in one of my user controls, I access this overridden requestModule like so:

    requestModuleOverride requestMod = (requestModuleOverride)HttpContext.Current.ApplicationInstance.Modules["umbracoRequestModule"];
    requestMod.myCustomMethod();

    On my local dev machine, this works just fine.

    However, when I try and access this user control from my staging site, I get an exception:

    Unable to cast object of type 'umbraco.presentation.requestModule' to type 'umbraco.presentation.requestModuleOverride'.

    My staging server is using the same line in web.config I posted above - that is, I specify umbraco.presentation.requestModuleOverride as the type for umbracoRequestModule. 

    If I change my user control to access the requestModule as the original type (not my overridden type), I can access it just fine.

     

    Can anyone suggest how I might start tracking this down - why does Umbraco use my custom type on my dev machine but use the default requestModule on the staging machine, ignoring my web.config?

  • Elwyn 8 posts 28 karma points
    Apr 14, 2011 @ 03:53
    Elwyn
    0

    OK, well, of course right after posting this I figured it out! (after being stuck on this for ages! doh!)

     

    So it turns out web.config defines these modules twice - I didn't look far enough down :p

     

    <system.webServer>
            <validation validateIntegratedModeConfiguration="false"/>
            <modules runAllManagedModulesForAllRequests="true">
                <remove name="umbracoRequestModule"/>
                <add name="umbracoRequestModule" type="umbraco.presentation.requestModule"/>

    Can anyone explain what this bit does? (why it removes the httpModule then re-adds it?)

     

    And why this only seems to happen on my staging site, not my local site? (my local web.config also has this remove > add bit as well...)

    Edit: OK, so after a bit of a google, system.web is for IIS6, and system.webServer is IIS7 - this makes sense!

     

Please Sign in or register to post replies

Write your reply to:

Draft