1 year ago
#244693
user2033412
UseFileServer with wildcard in path
I have wildcards in my API-Routes, like
[HttpGet("api/customers/{wildcard}/add")]
so that I can handle multiple instances of my application and manage the endpoints with a loadbalancer that knows where to redirect based on the wildcards value. I can then use the route
www.example.com/api/customers/contoso/add
No I want the same for the UI, but the following doesn't work:
var root = Directory.GetCurrentDirectory();
var fileServerOptions = new FileServerOptions()
{
EnableDefaultFiles = true,
EnableDirectoryBrowsing = false,
RequestPath = new PathString("/customers/{wildcard}/app"),
FileProvider = new PhysicalFileProvider(Path.Combine(root, "wwwroot"))
};
app.UseFileServer(fileServerOptions);
I cannot access the static file server via
www.example.com/customers/contoso/interface
it only works if I literally use
www.example.com/customers/{wildcard}/interface
Do you have any idea how I can accomplish the same behaviour that successfully works for the API-routes for the static file server aswell?
c#
asp.net-core
wildcard
fileserver
0 Answers
Your Answer