C# 如何从crystal report的ExportToStream在Web API中创建pdf流?

C# 如何从crystal report的ExportToStream在Web API中创建pdf流?,c#,angularjs,pdf,asp.net-web-api,crystal-reports,C#,Angularjs,Pdf,Asp.net Web Api,Crystal Reports,我在通过流媒体将crystal report导出为pdf时遇到问题。。 我正在使用Web Api,并且应该会将pdf流返回给我的客户端angularJS 这是我的密码 服务器端 <object data="{{content}}" width="100%" height="100%"> <div class="alert alert-danger text-center" style="border-radius:0"> You don't have PDF Plugi

我在通过流媒体将crystal report导出为pdf时遇到问题。。 我正在使用Web Api,并且应该会将pdf流返回给我的客户端angularJS

这是我的密码

服务器端

<object data="{{content}}" width="100%" height="100%">
 <div class="alert alert-danger text-center" style="border-radius:0">
You don't have PDF Plugin for this browser.  <a href="{{content}}">[ Click Here ]</a> to download the PDF File.
 </div>
 </object>
控制器

[Route("api/transcript")]
        [HttpPost]
        public async Task<HttpResponseMessage> Post(HttpRequestMessage request)
        {
            var content = request.Content;
            string jsonContent = content.ReadAsStringAsync().Result;

            // this code here is in repository. It will return ReportDocument.
            // It is functional and return the document file so i didnt include the code for this.
            ReportDocument rdoc = ITORRepo.LoadReport(jsonContent); 

            TOR _tor = JsonConvert.DeserializeObject<TOR>(jsonContent);
            string hdStudCode;
            hdStudCode = _tor.studCode;
            try
            {                   
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

                response.Content = new StreamContent(rdoc.ExportToStream(ExportFormatType.PortableDocFormat));
                response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                response.Content.Headers.ContentDisposition.FileName = "Transcript.pdf";

                return response;
            }
            catch (Exception)
            {
                //return string.Empty;
                throw;
            }
        }
HTML页面

<object data="{{content}}" width="100%" height="100%">
 <div class="alert alert-danger text-center" style="border-radius:0">
You don't have PDF Plugin for this browser.  <a href="{{content}}">[ Click Here ]</a> to download the PDF File.
 </div>
 </object>

您没有此浏览器的PDF插件。下载PDF文件。
这段代码有时起作用。。这意味着有时生成并显示pdf,但有时不显示

我的服务器端和客户端都没有错误

请告诉我我的代码有什么问题,为什么有时没有显示,有时有显示。。请帮助我解决问题的最佳方法是什么

非常感谢你