Any idea why Sitecore 9.3 would not pick up authenticated information of the user on a simple custom MVC controller method? I am trying to get the currently logged-in user, but it is showing Sitecore.Context.User as extranet\Anonymous even though the user is logged in. Cookies are being sent with the request.

I am guessing for some reason the request is not passing through Sitecore.Pipelines.HttpRequest.UserResolver, Sitecore.Kernel in the HttpBeginRequest pipeline.

Any ideas? I feel like this is a simple one.

  • If you are logging in the user with FederatedAuth , try checking Sitecore.Context.User.IsAuthenticated or IsLoggedIn methods
    – Abhay Dhar
    Dec 12 '20 at 17:53
  • IsAuthenticated was false, which I think we would expect when user is considered anonymous. Dec 13 '20 at 11:36

Perhaps the "page" (URL path) in which you're reading Sitecore.Context.User is in a Sitecore "site" which does not use the security domain that the user logged in to. E.g. your user logged into the "sitecore" security domain, but the web page you're testing is in your main public site, which doesn't use that security domain. This is a new issue I've discovered in Sitecore 9.3 vs. 8.2.

  • 1
    This was the issue. The api call was going to /sitecore/api... This did not match a site url and thus resolved to the "website" site. By changing the url to /sitecore/admin/api... the site resolved correctly and picked up the security information. Thank you for the pointer. Dec 13 '20 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.