Broken Protected Pages in Umbraco 4.5?

Today, while implementing the membership functionality for a new site I'm working feverishly on to get go live next week, I came across this error when I tried to access a Protected page while not logged in:


Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.Security.Membership.GetCurrentUserName() +68
   System.Web.Security.Membership.GetUser() +17
   umbraco.requestHandler..ctor(XmlDocument umbracoContent, String url) +8037
   umbraco.UmbracoDefault.Page_PreInit(Object sender, EventArgs e) +2534
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +41
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Page.OnPreInit(EventArgs e) +11042957
   System.Web.UI.Page.PerformPreInit() +41
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1255

As it turns out, it seems you need to add the runAllManagedModulesForAllRequests="true" attribute to the Modules node in your web.config file:

    <modules runAllManagedModulesForAllRequests="true">

Worked like a charm :)  Thank you Lee from Blogg Fodder UK, you saved me heaps of time with this one :)

2 comments for “Broken Protected Pages in Umbraco 4.5?”

  1. Posted Friday, October 29, 2010 at 5:47:03 PM

    Yeah I came across the same issue last year when working with session state. I also wrote a blog article about this. Had me stumped when I first saw it.

    http://www.littlewebempire.com/blog/2009/9/22/iis7-extensionless-urls-and-session-state

  2. Gravatar of Mads KrohnMads Krohn
    Posted Wednesday, November 30, 2011 at 12:03:28 AM

    Thank you soooo much, saved me hours!

Post a comment