来自于一个从服务端下载文件的需求。偶尔会出现中文乱码,待探究。

        public IActionResult Get()
        {
            const string str = @"D:\YaKun\Downloads\测试文件.txt";
            return new FileStreamResult(new FileStream(str, FileMode.Open), new MediaTypeHeaderValue("application/octet-stream"))
            {
                FileDownloadName = "测试文件.txt", //下载的文件名
                EnableRangeProcessing = true //文件流范围支持
            };
        }
最后修改:2023 年 01 月 09 日
如果觉得我的文章对你有用,请随意赞赏