FileServerExtensions Class

Extension methods that combine all of the static file middleware components: Default files, directory browsing, send file, and static files

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

Syntax

public class FileServerExtensions
class Microsoft.AspNetCore.Builder.FileServerExtensions

Methods

UseFileServer(Microsoft.AspNetCore.Builder.IApplicationBuilder)

Enable all static file middleware (except directory browsing) for the current request path in the current directory.

Return type:Microsoft.AspNetCore.Builder.IApplicationBuilder
public static IApplicationBuilder UseFileServer(this IApplicationBuilder app)
UseFileServer(Microsoft.AspNetCore.Builder.IApplicationBuilder, Microsoft.AspNetCore.Builder.FileServerOptions)

Enable all static file middleware with the given options

Return type:Microsoft.AspNetCore.Builder.IApplicationBuilder
public static IApplicationBuilder UseFileServer(this IApplicationBuilder app, FileServerOptions options)
UseFileServer(Microsoft.AspNetCore.Builder.IApplicationBuilder, System.Boolean)

Enable all static file middleware on for the current request path in the current directory.

Arguments:enableDirectoryBrowsing (System.Boolean) – Should directory browsing be enabled?
Return type:Microsoft.AspNetCore.Builder.IApplicationBuilder
public static IApplicationBuilder UseFileServer(this IApplicationBuilder app, bool enableDirectoryBrowsing)
UseFileServer(Microsoft.AspNetCore.Builder.IApplicationBuilder, System.String)

Enables all static file middleware (except directory browsing) for the given request path from the directory of the same name

Arguments:requestPath (System.String) – The relative request path.
Return type:Microsoft.AspNetCore.Builder.IApplicationBuilder
public static IApplicationBuilder UseFileServer(this IApplicationBuilder app, string requestPath)