ControllerBase.File Method

Definition

Overloads

File(String, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Returns the file specified by virtualPath (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Returns a file in the specified fileStream (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Byte[], String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Returns a file with the specified fileContents as content (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(String, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Returns the file specified by virtualPath (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Returns the file specified by virtualPath (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Returns a file in the specified fileStream (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Stream, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Returns a file in the specified fileStream (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Byte[], String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Returns a file with the specified fileContents as content (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Byte[], String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Returns a file with the specified fileContents as content (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(String, String, String, Boolean)

Returns the file specified by virtualPath (Status200OK) with the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Returns the file specified by virtualPath (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Stream, String, String, Boolean)

Returns a file in the specified fileStream (Status200OK) with the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Stream, String)

Returns a file in the specified fileStream (Status200OK), with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Byte[], String, String, Boolean)

Returns a file with the specified fileContents as content (Status200OK), the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Byte[], String)

Returns a file with the specified fileContents as content (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Stream, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Returns a file in the specified fileStream (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Byte[], String, Boolean)

Returns a file with the specified fileContents as content (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Byte[], String, String)

Returns a file with the specified fileContents as content (Status200OK), the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(String, String)

Returns the file specified by virtualPath (Status200OK) with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Stream, String, String)

Returns a file in the specified fileStream (Status200OK) with the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(String, String, Boolean)

Returns the file specified by virtualPath (Status200OK) with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(String, String, String)

Returns the file specified by virtualPath (Status200OK) with the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Byte[], String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Returns a file with the specified fileContents as content (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(Stream, String, Boolean)

Returns a file in the specified fileStream (Status200OK), with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

File(String, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns the file specified by virtualPath (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, string fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);

Parameters

virtualPath
String

The virtual path of the file to be returned.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created VirtualFileResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file in the specified fileStream (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);

Parameters

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created FileStreamResult for the response.

Attributes

Remarks

The fileStream parameter is disposed after the response is sent.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Byte[], String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file with the specified fileContents as content (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, string fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);

Parameters

fileContents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created FileContentResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(String, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns the file specified by virtualPath (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, string fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);

Parameters

virtualPath
String

The virtual path of the file to be returned.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

Returns

The created VirtualFileResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns the file specified by virtualPath (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);

Parameters

virtualPath
String

The virtual path of the file to be returned.

contentType
String

The Content-Type of the file.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created VirtualFileResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file in the specified fileStream (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);

Parameters

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

Returns

The created FileStreamResult for the response.

Attributes

Remarks

The fileStream parameter is disposed after the response is sent.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Stream, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file in the specified fileStream (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);

Parameters

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created FileStreamResult for the response.

Attributes

Remarks

The fileStream parameter is disposed after the response is sent.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Byte[], String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file with the specified fileContents as content (Status200OK), the specified contentType as the Content-Type, and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, string fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);

Parameters

fileContents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

Returns

The created FileContentResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Byte[], String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file with the specified fileContents as content (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag, bool enableRangeProcessing);

Parameters

fileContents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created FileContentResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(String, String, String, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns the file specified by virtualPath (Status200OK) with the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, string fileDownloadName, bool enableRangeProcessing);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, string? fileDownloadName, bool enableRangeProcessing);

Parameters

virtualPath
String

The virtual path of the file to be returned.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created VirtualFileResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns the file specified by virtualPath (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);

Parameters

virtualPath
String

The virtual path of the file to be returned.

contentType
String

The Content-Type of the file.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

Returns

The created VirtualFileResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Stream, String, String, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file in the specified fileStream (Status200OK) with the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string fileDownloadName, bool enableRangeProcessing);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string? fileDownloadName, bool enableRangeProcessing);

Parameters

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created FileStreamResult for the response.

Attributes

Remarks

The fileStream parameter is disposed after the response is sent.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Stream, String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file in the specified fileStream (Status200OK), with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType);

Parameters

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

Returns

The created FileStreamResult for the response.

Attributes

Remarks

The fileStream parameter is disposed after the response is sent.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Byte[], String, String, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file with the specified fileContents as content (Status200OK), the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, string fileDownloadName, bool enableRangeProcessing);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, string? fileDownloadName, bool enableRangeProcessing);

Parameters

fileContents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created FileContentResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Byte[], String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file with the specified fileContents as content (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType);

Parameters

fileContents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

Returns

The created FileContentResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Stream, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file in the specified fileStream (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);

Parameters

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

Returns

The created FileStreamResult for the response.

Attributes

Remarks

The fileStream parameter is disposed after the response is sent.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Byte[], String, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file with the specified fileContents as content (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, bool enableRangeProcessing);

Parameters

fileContents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created FileContentResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Byte[], String, String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file with the specified fileContents as content (Status200OK), the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, string fileDownloadName);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, string? fileDownloadName);

Parameters

fileContents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

Returns

The created FileContentResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(String, String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns the file specified by virtualPath (Status200OK) with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType);

Parameters

virtualPath
String

The virtual path of the file to be returned.

contentType
String

The Content-Type of the file.

Returns

The created VirtualFileResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Stream, String, String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file in the specified fileStream (Status200OK) with the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string fileDownloadName);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string? fileDownloadName);

Parameters

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

Returns

The created FileStreamResult for the response.

Attributes

Remarks

The fileStream parameter is disposed after the response is sent.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(String, String, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns the file specified by virtualPath (Status200OK) with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, bool enableRangeProcessing);

Parameters

virtualPath
String

The virtual path of the file to be returned.

contentType
String

The Content-Type of the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created VirtualFileResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(String, String, String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns the file specified by virtualPath (Status200OK) with the specified contentType as the Content-Type and the specified fileDownloadName as the suggested file name. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, string fileDownloadName);
C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.VirtualFileResult File (string virtualPath, string contentType, string? fileDownloadName);

Parameters

virtualPath
String

The virtual path of the file to be returned.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

Returns

The created VirtualFileResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Byte[], String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file with the specified fileContents as content (Status200OK), and the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileContentResult File (byte[] fileContents, string contentType, DateTimeOffset? lastModified, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTag);

Parameters

fileContents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

Returns

The created FileContentResult for the response.

Attributes

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

File(Stream, String, Boolean)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Returns a file in the specified fileStream (Status200OK), with the specified contentType as the Content-Type. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

C#
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, bool enableRangeProcessing);

Parameters

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created FileStreamResult for the response.

Attributes

Remarks

The fileStream parameter is disposed after the response is sent.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0