Mugshot

Hey I'm Lee. My blog was put up to house useful nuggets I could refer back to, document my learning curves on new technologies and house tutorials I write for Umbraco and other .NET stuff.

All thoughts and comments on here are my own, and in no way reflect my employer - I also take no responsibility for spelling, grammar or terminology, so read at your own risk!

Blogs I Read

Sites I Like

IIS7, Membership & Directory URLs

If you are having problems using ASP.NET membership within Umbraco using IIS7 with use Directory URLs set to true then this should solve your problems - Some of the issues you will see are

  • Unable to create / login users
  • Login status not working
  • Membership Methods Returning Null

This is the problem:

Default behaviour for iis7 for the formsauthentication module is to only invoke for requests to asp.net applications or managed handlers (probably also for iis6). If you disable the 'Invoke only for requests to ASP.NET applications or managed handlers' option, forms authentication will work then also for directory urls.

To solve the problem, do the following: [more]

  1. Open up IIS Manager
  2. Select the website you want to alter
  3. Double click on "Modules"
  4. Locate the parameter named "FormsAuthentication" and double click on it
  5. Uncheck the checkbox "Invoke only for requests to ASP.NET applications or managed handlers"
  6. Click OK

This will now solve all the membership problems, apart from one error - If you try to access a restricted page while NOT logged in, you'll get an error like this

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.Security.Membership.GetCurrentUserName() +37
   System.Web.Security.Membership.GetUser() +7
   umbraco.requestHandler..ctor(XmlDocument _umbracoContent, String url) +3493
   umbraco.UmbracoDefault.Page_PreInit(Object sender, EventArgs e) +903
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Page.OnPreInit(EventArgs e) +8699406
   System.Web.UI.Page.PerformPreInit() +31
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +282

To stop this happening you need to add the following attribute 'runAllManagedModulesForAllRequests' to the modules tag in the web.config

<modules runAllManagedModulesForAllRequests="true">

That should be it, everything should now work as it should - I hope this saves someone else the frustrating amount of hours I spent trying to figure it out.

Back to top