IvanJosipovic / BlazorApplicationInsights

Application Insights for Blazor web applications

Home Page:https://BlazorApplicationInsights.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to use SetAuthenticatedUserContext method in Blazor Server

techierathore opened this issue · comments

I am getting following error when I am trying to use SetAuthenticatedUserContext in Blazor Server application to record logged in user details after successful Azure AD authentication.
Can anyone please suggest a solution for this or is Blazor Server not supported ?
Screenshot 2023-02-16 at 12 45 43 PM

Hey,

This package should work fine with Blazor Sever, I think the issue you are experiance is that you are calling the AI JS function from OnInitializedAsync. This is not supported in Blazor server. JS calls need to be ran on OnAfterRenderAsync.

Please review, https://learn.microsoft.com/en-us/aspnet/core/blazor/components/lifecycle?view=aspnetcore-7.0