【发布时间】:2014-02-05 13:45:42
【问题描述】:
使用代码如:
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Buffer = True
HttpContext.Current.Response.ContentType = "application/CSV"
HttpContext.Current.Response.AppendHeader("content-disposition", "attachment;filename=FileName.csv")
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
HttpContext.Current.Response.Write(csvString.ToString())
HttpContext.Current.Response.[End]()
我可以通过网络服务调用提供 CSV 文件吗?它似乎不起作用我错过了什么?
我已经设置了一个传统的asp:button,它可以正确地提供文件,尽管 Web 服务返回一个 500 服务器错误Thread was being aborted
【问题讨论】:
-
如果我没记错的话,应该是 text/CSV
标签: .net web-services csv export-to-csv