これが電話です...
return new FileUriResult("application/octet-stream", a.AssetPath, null);
[わからないのでコンテンツの長さをnullに設定したことに注意してください(ファイルは別のサーバーにあります)]
a.AssetPathは次のとおりです: " http://http.cdnlayer.com/account name/folder/folder/folder/asset.mp3"
(この例の偽のURLですが、私の実装ではファイルを直接参照できますが、この添付方法は機能しません)
これが実装です...
public class FileUriResult : ActionResult
{
private string _contentType;
private string _fileUri;
private long? _fileLength;
public FileUriResult(string contentType, string fileUri, long? fileLength)
{
_contentType = contentType;
_fileUri = fileUri;
_fileLength = fileLength;
}
public override void ExecuteResult(ControllerContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
HttpResponseBase response = context.HttpContext.Response;
response.ContentType = _contentType;
response.AddHeader("Content-Disposition", "attachment; filename=" + _fileUri);
if(_fileLength != null)
response.AddHeader("Content-Length", _fileLength.ToString());
}
}
ファイルは私が望むように直接ダウンロードされています(ブラウザで開かれていません)が、ファイルではなく、同じ名前の0kbファイルです。