PhysicalFileResult Class

A Microsoft.AspNetCore.Mvc.FileResult on execution will write a file from disk to the response using mechanisms provided by the host.

Namespace
Microsoft.AspNetCore.Mvc
Assemblies
  • Microsoft.AspNetCore.Mvc.Core

Syntax

public class PhysicalFileResult : FileResult, IActionResult
class Microsoft.AspNetCore.Mvc.PhysicalFileResult

Constructors

PhysicalFileResult(System.String, Microsoft.Net.Http.Headers.MediaTypeHeaderValue)

Creates a new Microsoft.AspNetCore.Mvc.PhysicalFileResult instance with the provided <em>fileName</em> and the provided <em>contentType</em>.

Arguments:
public PhysicalFileResult(string fileName, MediaTypeHeaderValue contentType)
PhysicalFileResult(System.String, System.String)

Creates a new Microsoft.AspNetCore.Mvc.PhysicalFileResult instance with the provided <em>fileName</em> and the provided <em>contentType</em>.

Arguments:
  • fileName (System.String) – The path to the file. The path must be an absolute path.
  • contentType (System.String) – The Content-Type header of the response.
public PhysicalFileResult(string fileName, string contentType)

Methods

ExecuteResultAsync(Microsoft.AspNetCore.Mvc.ActionContext)
Return type:System.Threading.Tasks.Task
public override Task ExecuteResultAsync(ActionContext context)

Properties

Microsoft.AspNetCore.Mvc.PhysicalFileResult.FileName

Gets or sets the path to the file that will be sent back as the response.

Return type:System.String
public string FileName { get; set; }