Answer the question
In order to leave comments, you need to log in
What is the correct way to use the DefaultFilesOptions property inside the UseFileServer method?
Hello, this is a newbie question. I found the answer in Google, Stack and Habré, so I'm writing here (and if there is, then don't blame me).
I am studying ASP.NET Core and learned about the UseFileServer method, which combines three methods for working with static files. And I have a question: how to make the default file in it. Without it, it is done like this:
DefaultFilesOptions options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("start.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
app.UseFileServer(new FileServerOptions
{
DefaultFilesOptions = { DefaultFileNames = new[] {"start.html"}},
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question