FilePathResult Class¶
Summary¶
An [Microsoft.AspNet.Mvc.ActionResult]() that when executed will write a file from disk to the response using mechanisms provided by the host.
Constructors¶
-
FilePathResult
(System.String, MediaTypeHeaderValue)¶ Creates a new [Microsoft.AspNet.Mvc.FilePathResult](Microsoft.AspNet.Mvc.FilePathResult.yml) instance with the provided <paramref name=”fileName” /> and the provided <paramref name=”contentType” />.
Arguments: - fileName (System.String) – The path to the file. The path must be an absolute path. Relative and virtual paths are not supported.
- contentType (MediaTypeHeaderValue) – The Content-Type header of the response.
public FilePathResult(string fileName, MediaTypeHeaderValue contentType)
-
FilePathResult
(System.String, System.String) Creates a new [Microsoft.AspNet.Mvc.FilePathResult](Microsoft.AspNet.Mvc.FilePathResult.yml) instance with the provided <paramref name=”fileName” /> and the provided <paramref name=”contentType” />.
Arguments: - fileName (System.String) – The path to the file. The path must be an absolute path. Relative and virtual paths are not supported.
- contentType (System.String) – The Content-Type header of the response.
public FilePathResult(string fileName, string contentType)
-
Methods¶
-
IsPathRooted
(System.String)¶ Determines if the provided path is absolute or relative. The default implementation considers paths starting with ‘/’ to be relative.
Arguments: - path (System.String) – The path to examine.
Return type: System.Boolean
Returns: True if the path is absolute.
protected virtual bool IsPathRooted(string path)
-
NormalizePath
(System.String)¶ Creates a normalized representation of the given <paramref name=”path” />. The default implementation doesn’t support files with ‘’ in the file name and treats the ‘’ as a directory separator. The default implementation will convert all the ‘’ into ‘/’ and will remove leading ‘~’ characters.
Arguments: - path (System.String) – The path to normalize.
Return type: System.String
Returns: The normalized path.
protected virtual string NormalizePath(string path)
-
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)
-