如何将只读属性设置为FileContentResult

时间:2019-02-14 15:35:25

标签: c# .net-core

我正在控制器中生成一个新文件,并像这样返回它:

[HttpPost]
[Route("configurationFile")]
public async Task<IActionResult> Post([FromBody] ConfigDto request)
{
    var jsonBytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(request));
    return new FileContentResult(jsonBytes, "application/json")
    {
        FileDownloadName = $"Configuration_{DateTime.UtcNow:yyyyMMdd_HHmmss}.config"
    };
}       

如何将属性设置为只读文件?

0 个答案:

没有答案