为什么只下载txt文件?

我正在尝试在ASP.NETWebAPI中下载文件。如果我尝试.xsl.pdf.docx...等格式文件,即使下载了也是无序的文件,但是txt格式的没有任何问题。这是我的API代码:

        public HttpResponseMessage GetFile(DownloadInput input)
    {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
        var fileNm = input.fiName;
        string filePath = (@"C:\Uploads\" + input.folderName + @"\" + fileNm);
        if (!File.Exists(filePath))
            {
                response.StatusCode = HttpStatusCode.NotFound;
                response.ReasonPhrase = string.Format("File not found: {0} .", fileNm);
                throw new HttpResponseException(response);
            }
            byte[] bytes = File.ReadAllBytes(filePath);
            response.Content = new ByteArrayContent(bytes);
            response.Content.Headers.ContentLength = bytes.LongLength;
            response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = fileNm;    
            response.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping(filePath));
            return response;
    }

我的ajax代码:

        function DownloadFile(fiName,foName) {
        var UserData = {
            "folderName":  "" + foName+ "",
            "fiName":  "" + fiName + "",
        };
        var userDataJson = JSON.stringify(UserData);
        $.ajax({
            url: "http://localhost:9000/api/Calendar/GetFile",
            type: "POST",
            contentType: "application/json",
            data: userDataJson,
            success: function (response, xhr, request) {
                let contentType = request.getResponseHeader('Content-Type');
                let blob = new Blob([response], {
                    type: contentType
                });
                let link = document.createElement('a');
                link.href = window.URL.createObjectURL(blob);
                link.download = ad;
                link.click();
            },
            error: function (err) {
                console.log(JSON.stringify(err));
            }
        });
多谢!
不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^