Серверная часть Blazor .Net 8 не перенаправляетсяC#

Место общения программистов C#
Ответить
Гость
 Серверная часть Blazor .Net 8 не перенаправляется

Сообщение Гость »


У меня возникла проблема с перенаправлением. Я объясню свою проблему в двух случаях
Случай 1:
Перенаправление на page never succeed. What am I missing here?
Case 2:
Redirection to page succeed at local development but not when I deployed to IIS. Everything work like it should at local but when at server I'm facing error

Код: Выделить всё

HTTP ERROR 500
. Below are the lines I've been tried so far.
I'm using a controller for authentication process, the redirection I've made at controller seems ok it redirect me to after successful login also the logout process seems ok.
P/S: I created the

Код: Выделить всё

BlankLayout.razor
in the folder

Код: Выделить всё

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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»