我正在控制器中生成一个新文件,并像这样返回它:
[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"
};
}
如何将属性设置为只读文件?