Blazor Server Cookie & Role Handling

Job ID: 39885129

Budget: €8 – €30 EUR

I have cloned Microsoft’s Blazor Server Azure AD sample (https://github.com/Azure-Samples/ms-identity-docs-code-dotnet/tree/main/web-app-blazor-server) and just need a few targeted tweaks:

• Cookie behaviour
– The auth cookie must last exactly 24 hours.
– It must remain valid after the browser is closed and reopened within that period.

• Role-loading demo
– Add Services/UserService.cs that only simulates pulling roles from a database.
– The service should fire once on initial sign-in and again if the user clicks the “Re-login” link.
– It must NOT run on a simple page refresh (F5) while the cookie is still valid.

No database wiring or extra UI work is required—just the minimal code changes, comments where useful, and a brief note explaining where you modified Program.cs or the authentication options.

Deliver the updated solution or a diff against the original repo so I can test it quickly.


Updated LoginDisplay.razor
<AuthorizeView>
<Authorized>
Hello, @context.User.Identity.Name!
<a href="MicrosoftIdentity/Account/SignOut">Sign Out</a>
<a href="MicrosoftIdentity/Account/SignIn?prompt=login">Re-login</a>
</Authorized>
<NotAuthorized>
<a href="MicrosoftIdentity/Account/SignIn">Sign In</a>
</NotAuthorized>
</AuthorizeView>