diff --git a/src/OrchardCoreContrib.Users/Views/UserMenu.cshtml b/src/OrchardCoreContrib.Users/Views/UserMenu.cshtml
index 78813b1..f02b524 100644
--- a/src/OrchardCoreContrib.Users/Views/UserMenu.cshtml
+++ b/src/OrchardCoreContrib.Users/Views/UserMenu.cshtml
@@ -2,21 +2,68 @@
@using OrchardCore.Users
@using OrchardCoreContrib.Avatars
@using Microsoft.AspNetCore.Authorization
+@using Microsoft.Extensions.DependencyInjection
@using System.Security.Claims
@inject IAuthorizationService AuthorizationService
-@inject IAvatarService AvatarService
@attribute [Feature("OrchardCoreContrib.Users.Avatar")]
+
+@* Same as the stock OrchardCore.Users UserMenu.cshtml for anonymous visitors. *@
+@if (!User.Identity.IsAuthenticated)
+{
+ @if (Model.AnonymousContent?.Items != null && Model.AnonymousContent.Items.Count > 0)
+ {
+
+
+ @if (Model.AnonymousHeader?.Items != null && Model.AnonymousHeader.Items.Count > 0)
+ {
+ @await DisplayAsync(Model.AnonymousHeader)
+ }
+ else
+ {
+ @T["Users"]
+ }
+
+
+
+
+
+ return;
+ }
+
+
+
+ @T["Log in"]
+
+
+
+ return;
+}
+
@{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
- var avatar = AvatarService.GetAvatar(new AvatarContext { DisplayName = User.Identity.Name });
+ // Orchard Core binds a module's shape templates to every enabled feature of the module, so this
+ // view is active whenever any OrchardCoreContrib.Users feature is (e.g. only Impersonation), not
+ // just Avatar. IAvatarService comes from the Avatar feature (or another avatar provider, or the
+ // NullAvatarService fallback of AddOrchardCoreContrib()), so resolve it optionally.
+ var avatarService = Context.RequestServices.GetService();
+ var avatar = avatarService?.GetAvatar(new AvatarContext { DisplayName = User.Identity.Name });
}