Asp.net mvc 4 jsreports未向文件添加.csv扩展名

Asp.net mvc 4 jsreports未向文件添加.csv扩展名,asp.net-mvc-4,csv,jsreport,Asp.net Mvc 4,Csv,Jsreport,我正在使用mysite.jsreportsonline.net创建一个csv,供最终用户下载。在我登录的jsreports站点上,它的功能应该是提示我下载扩展名为.csv的文件。出于某种原因,在我的MVC4应用程序中,它会提示下载,但不会添加.csv扩展名。在我的控制器中,我使用登录凭据从mysite.jsreportonline.net中提取报告。有什么线索可以解释为什么会发生这种情况吗?jsreport响应头包括以下内容 Content-Disposition: attachment;fil

我正在使用mysite.jsreportsonline.net创建一个csv,供最终用户下载。在我登录的jsreports站点上,它的功能应该是提示我下载扩展名为.csv的文件。出于某种原因,在我的MVC4应用程序中,它会提示下载,但不会添加.csv扩展名。在我的控制器中,我使用登录凭据从mysite.jsreportonline.net中提取报告。有什么线索可以解释为什么会发生这种情况吗?

jsreport响应头包括以下内容

Content-Disposition: attachment;filename=report.csv  
这将指示浏览器打开report.csv的下载对话框


如果我理解正确,您可以从控制器向jsreport发出post请求,然后返回返回的流。您需要确保将这样的标题也添加到响应中。

jsreport响应标题包括以下内容

Content-Disposition: attachment;filename=report.csv  
这将指示浏览器打开report.csv的下载对话框


如果我理解正确,您可以从控制器向jsreport发出post请求,然后返回返回的流。您需要确保将这样的标题也添加到响应中。

因此我使用了
response.AppendHeader
错误。以下是它应该如何编码:

Response.AppendHeader("Content-Disposition", "attachment; filename=filename.csv");
Response.ContentType = "application/octet-stream";

所以我使用了
Response.AppendHeader
错误。以下是它应该如何编码:

Response.AppendHeader("Content-Disposition", "attachment; filename=filename.csv");
Response.ContentType = "application/octet-stream";

我使用的是允许url字符串、用户名和密码的
ReportingService
,以及允许shortid和输入数据的
\u ReportingService.RenderAsync
。尝试添加
Response.AddHeader
,但无效。还尝试了
FileExtension=“csv”这也不起作用。从mvc控制器返回文件似乎是一个很常见的问题。您应该能够像任何其他报告流一样返回jsreport流。你试过这样的吗?我正在添加
Response.AppendHeader(“内容配置:附件;文件名=filename.csv”,report.ToString())返回的是“filename.csv-jsreport.Client.Report”作为要另存为的文件名。仍然不工作。使用
System.Web.HttpContext.Current.Application.Remove(“-jsreport.Client.Report”)
System.Web.HttpContext.Current.Response.ClearContent()
System.Web.HttpContext.Current.Response.ClearHeaders()
Response.AppendHeader(“内容处置:”+“附件;文件名=report.csv”,report.ToString())
System.Web.HttpContext.Current.Response.ContentType=“application/vnd.ms excel”ReportingService
,它允许url字符串、用户名和密码,以及
\u ReportingService.RenderAsync
,它允许短ID和输入数据。尝试添加
Response.AddHeader
,但无效。还尝试了
FileExtension=“csv”这也不起作用。从mvc控制器返回文件似乎是一个很常见的问题。您应该能够像任何其他报告流一样返回jsreport流。你试过这样的吗?我正在添加
Response.AppendHeader(“内容配置:附件;文件名=filename.csv”,report.ToString())返回的是“filename.csv-jsreport.Client.Report”作为要另存为的文件名。仍然不工作。使用
System.Web.HttpContext.Current.Application.Remove(“-jsreport.Client.Report”)
System.Web.HttpContext.Current.Response.ClearContent()
System.Web.HttpContext.Current.Response.ClearHeaders()
Response.AppendHeader(“内容处置:”+“附件;文件名=report.csv”,report.ToString())
System.Web.HttpContext.Current.Response.ContentType=“application/vnd.ms excel”