Mein Problem, das ich jetzt habe, ist, dass ich den Zugriff immer noch anonym gewähren möchte, wenn ich mich im Debugging-Modus befinde.
Für die Controller-Authentifizierung habe ich verwenden:
Code: Select all
app.MapControllers()
.WithMetadata(new AllowAnonymousAttribute());
Code: Select all
app.MapFallbackToFile("/StaticFiles/{*filepath}")
.WithMetadata(new AllowAnonymousAttribute());
Die statische Dateifunktion ist:
Code: Select all
builder.Services.AddAuthorization(options =>
{
options.FallbackPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
});
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(builder.Environment.ContentRootPath, staticFiles)),
RequestPath = "/StaticFiles"
});
Vielen Dank