Reputation: 1527
Good day everyone.
I have tried several to make static files working through routing but is does not seem to work in IIS.
My current approach is this:
app.MapWhen(context =>
{
var path = context.Request.Path.Value;
return path.StartsWith("/Images", StringComparison.OrdinalIgnoreCase);
}, config => config.UseStaticFiles());
Any clues what should I do in order make static files routing working?
Upvotes: 0
Views: 2071
Reputation: 949
Here is an example how you can access static Files in a folder named "Content" in the project Root.
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "Content")),
RequestPath = "/Content"
});
ex: http://localhost/content/myfile.html
Upvotes: 1