Blazor WASM hosted custom API authorize returns index.html instead of JSON

Resolution:

builder.Services.ConfigureApplicationCookie(c =>
{
    c.Events.OnRedirectToLogin = c.Events.OnRedirectToAccessDenied = context =>
    {
        context.Response.StatusCode = StatusCodes.Status401Unauthorized;

        return Task.CompletedTask;
    };
});
创建时间:2/25/2023 9:45:37 PM 修改时间:2/25/2023 9:46:14 PM