FileContentResult Class

Represents an Microsoft.AspNetCore.Mvc.ActionResult that when executed will write a binary file to the response.

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

Syntax

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

Constructors

FileContentResult(System.Byte[], Microsoft.Net.Http.Headers.MediaTypeHeaderValue)

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

Arguments:
public FileContentResult(byte[] fileContents, MediaTypeHeaderValue contentType)
FileContentResult(System.Byte[], System.String)

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

Arguments:
  • fileContents (System.Byte<System.Byte>[]) – The bytes that represent the file contents.
  • contentType (System.String) – The Content-Type header of the response.
public FileContentResult(byte[] fileContents, string contentType)

Methods

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

Properties

Microsoft.AspNetCore.Mvc.FileContentResult.FileContents

Gets or sets the file contents.

Return type:System.Byte<System.Byte>[]
public byte[] FileContents { get; set; }