文件名规范不起作用?

Filename specification not working?

我有一个 FileResult class 受到 SO post 的启发,看起来像这样:

public class FileResult : IHttpActionResult
{
    private readonly Stream _content;
    private readonly string _contentType;
    private readonly string _filename;
    private readonly HttpStatusCode _status;

    public FileResult(Stream content, string filename, string contentType = null, HttpStatusCode status = HttpStatusCode.OK)
    {
        _filename = filename;
        _contentType = contentType;
        _content = content;
        _status = status;
    }

    public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
    {
        return Task.Run(() =>
            {
                var response = new HttpResponseMessage(_status)
                {
                    Content = new StreamContent(_content)
                };

                var contentType = _contentType ?? MimeMapping.GetMimeMapping(_filename);
                response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = _filename,
                    Size = _content.Length
                };
                response.Content.Headers.ContentLength = _content.Length;

                return response;
            },
            cancellationToken);
    }
}

我将其连接到我的网络 api 控制器中,如下所示:

[Route("~/campaigns/{campaignId}/creativetemplate")]
[HttpGet]
public async Task<IHttpActionResult> GetBulkEditSheetForCampaign(int campaignId)
{
    var sheetStream = await _creativeBulkOperationService.GenerateBulkCreativeEditSpreadsheet(campaignId);
    return new FileResult(sheetStream, $"CreativeEditSheet_{campaignId}.xslx");
}

当我用 RESTful 客户端调用它时,文件保存为 creativetemplate。我希望它被保存为类似于 CreativeEditSheet_1234567890.xslx 的东西。我是做错了什么,还是这是客户端行为?

看起来共识是我做对了,但我使用的客户端忽略了它...这既是好消息(我没有搞砸任何事情)也是坏消息(现在我必须找到更好的客户)。

感谢所有参与调查的人。