Jonathan
Jonathan
Explore posts from servers
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
So I found that it is something wrong with safari and the cookies or storage on my machine, I cleaned everything and it is running fine
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
yeah yours is working let me see if I can find the differences
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
yeah lets try that
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
yeah that is working
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
I tried it on another computer and the same thing from a completely new project and made sure the only thing I did was replace the Home.razor
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
Maybe I am completely going this the wrong way, I just need to get my current user so I can ensure it is filtered down to their data
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
But if you go to the page https://localhost:7126/Account/Manage it is obviously working
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
and no go
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
right, I tried adding:
builder.Services.AddHttpContextAccessor();
builder.Services.AddHttpContextAccessor();
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
to match this:
@page "/"
@using ExampleIssues.Components.Account
@using ExampleIssues.Data
@inject IdentityUserAccessor UserAccessor

<PageTitle>Home</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

@if (user != null)
{
<div>User here: @user.UserName</div>
}
else
{
<div>User Not found</div>
}

@code {

private ApplicationUser user = default!;

[CascadingParameter] private HttpContext HttpContext { get; set; } = default!;
protected override async Task OnInitializedAsync()
{
user = await UserAccessor.GetRequiredUserAsync(HttpContext);
}
}
@page "/"
@using ExampleIssues.Components.Account
@using ExampleIssues.Data
@inject IdentityUserAccessor UserAccessor

<PageTitle>Home</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

@if (user != null)
{
<div>User here: @user.UserName</div>
}
else
{
<div>User Not found</div>
}

@code {

private ApplicationUser user = default!;

[CascadingParameter] private HttpContext HttpContext { get; set; } = default!;
protected override async Task OnInitializedAsync()
{
user = await UserAccessor.GetRequiredUserAsync(HttpContext);
}
}
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
I just created a new blank project again, and the only thing i changed was the home page
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
If you login and go to the home page, it just loops
26 replies
CC#
Created by Jonathan on 5/6/2024 in #help
Error Accessing a User in Blazor
I replaced my App.razor with that and it just goes in a loop of reloading
26 replies