I'm getting the following exception when attempting to browse to my site :
The configuration/staticcontent
endpoint is implemented like so:
[HttpGet("staticcontent")]
public async Task<IActionResult> GetStaticContent()
{
return Ok(this.mapper.Map<StaticContentValueDto[]>(await this.staticContentValuesProvider.GetStaticContentValues()));
}
.. .and the implementation of GetStaticContentValues()
as follows:
public async Task<IEnumerable<StaticContentValue>> GetStaticContentValues()
{
return await this.dbContext.StaticContentValues.ToArrayAsync();
}
I suspect there might be an issue with AD authentication?
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; });
services.AddMvcCore()
.AddAuthorization();
services.AddControllers().AddNewtonsoftJson(o=>
{
o.SerializerSettings.ContractResolver = new DefaultContractResolver();
o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
string connection = Configuration.GetConnectionString("DefaultConnection");
string reportingConnection = Configuration.GetConnectionString("ReportingConnection");
services.AddDbContext<PnbIdentityDbContext>(options =>
options.UseSqlServer(connection));
//20 or so other adddbcontext for sql server here
//20 or so other adddbcontext for sql server here
services.AddIdentity<PnbIdentityUser, PnbIdentityRole>(options => {
options.Password.RequireDigit = true;
options.Password.RequiredLength = 8;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false;
options.Password.RequireLowercase = false;
})
.AddEntityFrameworkStores<PnbIdentityDbContext>()
.AddDefaultTokenProviders();
services.AddAutoMapper(typeof(CapsAutoMapperProfile));
SessionConfigurator.Configure(services);
AuthConfigurator.Configure(services, Configuration["Identity:TokenSecret"]);
DiConfigurator.Configure(services);
HangfireConfigurator.Configure(services, connection);
}
Please note that Identity:TokenSecret
is set in appsettings.json.
What am I doing wrong? What is the reason for the 401 response?