DefaultFilesMiddleware Class

This examines a directory path and determines if there is a default file present. If so the file name is appended to the path and execution continues. Note we don’t just serve the file because it may require interpretation.

Namespace
Microsoft.AspNetCore.StaticFiles
Assemblies
  • Microsoft.AspNetCore.StaticFiles

Syntax

public class DefaultFilesMiddleware
class Microsoft.AspNetCore.StaticFiles.DefaultFilesMiddleware

Constructors

DefaultFilesMiddleware(Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Hosting.IHostingEnvironment, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Builder.DefaultFilesOptions>)

Creates a new instance of the DefaultFilesMiddleware.

Arguments:
public DefaultFilesMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions<DefaultFilesOptions> options)

Methods

Invoke(Microsoft.AspNetCore.Http.HttpContext)

This examines the request to see if it matches a configured directory, and if there are any files with the configured default names in that directory. If so this will append the corresponding file name to the request path for a later middleware to handle.

Return type:System.Threading.Tasks.Task
public Task Invoke(HttpContext context)