У меня возникла проблема с перенаправлением. Я объясню свою проблему в двух случаях
Случай 1:
Перенаправление на
Код: Выделить всё
Case 2:
Redirection to
Код: Выделить всё
Login
Код: Выделить всё
HTTP ERROR 500
I'm using a controller for authentication process, the redirection I've made at controller seems ok it redirect me to
Код: Выделить всё
/home
P/S: I created the
Код: Выделить всё
BlankLayout.razor
Код: Выделить всё
Layout
Код: Выделить всё
Routes.razor
Код: Выделить всё
There is nothing over here
Код: Выделить всё
RedirectToLogin
Код: Выделить всё
@inject NavigationManager NavigationManager
@attribute [AllowAnonymous]
@code {
protected override void OnInitialized()
{
NavigationManager.NavigateTo($"/login?returnUrl={Uri.EscapeDataString(NavigationManager.Uri)}", forceLoad: true);
}
}
Код: Выделить всё
Program.cs
Код: Выделить всё
builder.Services.AddAuthorization();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(x =>
{
x.LoginPath = "/login";
x.LogoutPath = "/auth/logout";
});
builder.Services.AddControllers();
builder.Services.AddScoped();
builder.Services.ConfigureApplicationCookie(x =>
{
x.EventsType = typeof(CookieEvent);
});
Источник: https://stackoverflow.com/questions/781 ... t-redirect