-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed as not planned
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issuePillar: Dev ExperienceStatus: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing one
Milestone
Description
I have a Login Form inside a Blazor Server App which is working fine with built-in functionality.
But now I am trying to solve a problem where I will be allowing Users to log in automatically when they reach from certain URL and with certain parameters, Without submitting a form
I tried this in my Login Component
protected override async Task OnInitializedAsync() {
try {
if (HttpMethods.IsGet(HttpContext.Request.Method))
await HttpContext.SignOutAsync();
if (parameter && condition) {
await DirectLogin();
}
} catch (Exception ex) {
_logger.LogError(message: ex.Message);
}
}
async Task DirectLogin() {
try {
//Perform some logic here and then SignIn
await HttpContext.SignInAsync(principal, new AuthenticationProperties {
ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(5)
});
_navigation.NavigateTo($"/direct/page/{parameter}", true);
//Here I get this exception "Microsoft.AspNetCore.Components.NavigationException"
} catch (Exception ex) {
errorMessage = $ "Error: {ex.Message}";
_logger.LogError(message: ex.Message);
}
}
This login Component is in a Static Server Render mode whereas after the successful SignIn, the User will be redirected to an Interactive Server Component.
But Navigation is not working and I am getting this exception
Exception of type 'Microsoft.AspNetCore.Components.NavigationException' was thrown
Originally posted by @mohiyo in #49472 (comment)
Metadata
Metadata
Assignees
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issuePillar: Dev ExperienceStatus: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing one