Table of Contents

Class FileResult

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

Represents a base class that is used to send binary file content to the response.

public abstract class FileResult : ActionResult
Inheritance
FileResult
Derived
Inherited Members

Constructors

FileResult(string)

Initializes a new instance of the FileResult class.

protected FileResult(string contentType)

Parameters

contentType string

The type of the content.

Exceptions

ArgumentException

The contentType parameter is null or empty.

Properties

ContentType

Gets the content type to use for the response.

public string ContentType { get; }

Property Value

string

The type of the content.

FileDownloadName

Gets or sets the content-disposition header so that a file-download dialog box is displayed in the browser with the specified file name.

public string FileDownloadName { get; set; }

Property Value

string

The name of the file.

Methods

ExecuteResult(ControllerContext)

Enables processing of the result of an action method by a custom type that inherits from the ActionResult class.

public override void ExecuteResult(ControllerContext context)

Parameters

context ControllerContext

The context within which the result is executed.

Exceptions

ArgumentNullException

The context parameter is null.

WriteFile(HttpResponseBase)

Writes the file to the response.

protected abstract void WriteFile(HttpResponseBase response)

Parameters

response HttpResponseBase

The response.