Session.UserId returns NULL during Debug in Personal Area

Session.UserId returns NULL during Debug in Personal Area

There is a quirk that I have come across a few times that has left me scratching my head.

When debugging in a Personal Area and opening a page I get an invalid permissions error for the page.

The user that is logged into the site can access the Public Ara but not the Personal Area.

The user has been able to access the page in the Personal Area all day and no permission have been changed on the page in  weeks.

Putting a breakpoint on the page I can see that Session.UserId is NULL in the Personal Area but has the UserId in the Public Area.

I have thrown my hands up in frustration at this problem previously and walked away for a coffee. On return I have found the problem magically resolved and I continue on my merry way.

Murphy's Law states that this problem will occur late at night or before a major deadline and I would like to understand how to "un-jam" the Session.UserId so that I can continue working in the Personal Area (without using undue force on the laptop).

Hi Ouen,

You probably know this, but the user session in the public area is different from the session in the personal area. If you are logged in one, you are not necessarily logged in the other.

Depending on how you have built your login flow, you may be switching between screens in the public and personal areas. I've seen some situations in which the developer always redirects to the public area login screen, or after login, always redirects to the public area destination screen (thus leaving the personal area).

If you're able to replicate this pattern, look at the URL in the browser for each screen transition (during the login flow) and check if you're indeed leaving your personal area (this will have your username in the URL).

It's hard to pinpoint the problem without replicating it, hopefully you can it working.

There is a redirection taking place to the public area.

What is the pattern to follow to force the redirect to a private area login screen when the login screen is in a seperate module?


Using the default login flow it should work.

Be sure to access your login screen in the personal area (usually at http://<server>/eSpace/<username>/Login.aspx).

If you're using External Site redirections with dynamic URLs, you may want to use action AddPersonalAreaToURLPath(URL) to automatically add the Personal Area to the URL, if applicable.