我使用的是ASP。. NET MVC &;在React中,我还添加了脚手架项目并迁移了数据库。
我正在尝试登录或注册,但在我已经注册或登录后,这个错误显示,这个错误总是显示。
未处理的拒绝(错误):无法加载设置的应用程序。网络"AuthorizeService.ensureUserManagerInitialized
AuthorizeService.ensureUserManagerInitialized
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultUI()
.AddDefaultTokenProviders();
services.AddControllersWithViews();
services.AddRazorPages();
services.AddMvc(options =>
{
//**************Add General Policy *********************
//User need to be a Authorized system user to access pages except allowAnonymous annotation
var generalPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(generalPolicy));
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
});
有谁能帮我一下吗,谢谢
变更授权参考
添加AllowAnonymous到OidcConfigurationController
[AllowAnonymous]
public class OidcConfigurationController : Controller
{
private readonly ILogger<OidcConfigurationController> _logger;
public OidcConfigurationController(IClientRequestParametersProvider
clientRequestParametersProvider, ILogger<OidcConfigurationController>
logger)
{
ClientRequestParametersProvider = clientRequestParametersProvider;
_logger = logger;
}
public IClientRequestParametersProvider ClientRequestParametersProvider
{ get; }
[HttpGet("_configuration/{clientId}")]
public IActionResult GetClientRequestParameters([FromRoute]string clientId)
{
var parameters =
ClientRequestParametersProvider.GetClientParameters(HttpContext,
clientId);
return Ok(parameters);
}
}