I have an app .NET core 2.1 with this code:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "Assets")),
RequestPath = "/Assets"
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseMvc();
}
and my structure folder:
but none of these urls open the image:
"my-website.com/images/snes/alien.jpg"
"my-website.com/wwwroot/images/snes/alien.jpg"
"my-website.com/Assets/Snes/alien.jpg"
anybody know what is wrong?
Edit: Here is the folder get by CurrentDirectoy() method (apparently is correct):
Edit2: With this code work on localhost but not when i publish on azure:
app.UseFileServer(
new FileServerOptions()
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"))
});