System.InvalidOperationException: не указана аутентификацияScheme, и не найдено DefaultForbidScheme. Схемы по умолчанию можно установить с помощью AddAuthentication(string defaultScheme) или AddAuthentication(Action configureOptions).
Код, который я использую в своем контроллере:< /p>
Код: Выделить всё
if (!user.Email.Equals("my Dummy Address"))
{
return Forbid();
}
Код: Выделить всё
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddAuthentication(BearerTokenDefaults.AuthenticationScheme);
Подробнее здесь: https://stackoverflow.com/questions/789 ... sp-net-mvc