//Startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
.....
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "static")),
RequestPath = "/static"
});
.....
}
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-5.0
ถ้ามีการ authen ก่อน
เอาโค้ดไว้ล่าง app.UseAuthentication();
https://dev.to/j_sakamoto/how-can-i-protect-static-files-with-authorization-on-asp-net-core-4l0o