FileContentResult Class

Summary

Represents an [Microsoft.AspNet.Mvc.ActionResult]() that when executed will write a binary file to the response.

Syntax

public class FileContentResult : FileResult, IActionResult

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.FileContentResult

Constructors

FileContentResult(System.Byte[], MediaTypeHeaderValue)

Creates a new [Microsoft.AspNet.Mvc.FileContentResult](Microsoft.AspNet.Mvc.FileContentResult.yml) instance with the provided <paramref name=”fileContents” /> and the provided <paramref name=”contentType” />.

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

Creates a new [Microsoft.AspNet.Mvc.FileContentResult](Microsoft.AspNet.Mvc.FileContentResult.yml) instance with the provided <paramref name=”fileContents” /> and the provided <paramref name=”contentType” />.

Arguments:
  • fileContents (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)

Properties

FileContents()

Gets or sets the file contents.

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

Methods

WriteFileAsync(HttpResponse, System.Threading.CancellationToken)
Arguments:
  • response (HttpResponse) –
  • cancellation (System.Threading.CancellationToken) –
Return type:

System.Threading.Tasks.Task

protected override Task WriteFileAsync(HttpResponse response, CancellationToken cancellation)