My question is: how can I get Umbraco to immediately recognize that the member is logged in when I call the Members.Login() method in a custom RenderMvcController?
Here’s the background:
I have an Umbraco 8 stand-alone install (not cloud), running an intranet site. We have the site set up in IIS to do windows authentication so we can get the username of the currently logged in user accessing the intranet site.
Most of the site is accessible to all staff. Parts of it, however, are only accessible to certain members. We’ve set up those parts to use member group restrictions.
When a user access any page of the site, we get their ActiveDirectory name and email address and add them to the Umbraco members (with a temporary password), if they aren’t already an Umbraco member - using Members.RegisterMember().
Then, whether they were just added or not, we auto-log them in using the Members.Login() method.
All of this is done in a custom RenderMvcController that has been set as the default using a composer implementing IUserComposer.
Unfortunately, on the very first visit to the site, the page the member loads does not recognize them as logged in. The member is created if needed and has been logged in, but the page doesn’t recognize that. If they reload the page or navigate to another page, they are recognized as logged in. I’m guessing that the MembershipHelper has cached their status already and the Members.Login() method doesn’t change that.
So what do I need to do to a) get the cache reset? b) force the page to reload? c) a better way of auto-logging in a member? d) other?
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/103887-umbraco-membership-auto-login-problem-on-first-page-load