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 :)