Asp.net WebApi下载文件
1,图片
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ByteArrayContent(stream)
};
result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
2,文件
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StreamContent(stream);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "Wep Api Demo File.zip"
};
Asp.net WebApi下载文件的更多相关文章
- Asp.net mvc 下载文件
前言 最近有需求需要下载文件,可能是image的图片,也可能是pdf报告,也可能是微软的word或者excel文件. 这里就整理了asp.net mvc 和asp.net webapi 下载的方法 A ...
- asp.net mvc5 下载文件方法
控制器自带的 FileContentResult 可以让我们很方便的返回文件到服务端,减少了很多步骤.用于下载文件的时候,像视频.文本.图片这种浏览器支持的文件,默认就会被浏览器打开.这时候想让它变成 ...
- ASP.NET批量下载文件的方法
一.实现步骤 在用户操作界面,由用户选择需要下载的文件,系统根据所选文件,在服务器上创建用于存储所选文件的临时文件夹,将所选文件拷贝至临时文件夹.然后调用 RAR程序,对临时文件夹进行压缩,然后输出到 ...
- ASP.NET批量下载文件
一.实现步骤 在用户操作界面,由用户选择需要下载的文件,系统根据所选文件,在服务器上创建用于存储所选文件的临时文件夹,将所选文件拷贝至临时文件夹.然后调用 RAR程序,对临时文件夹进行压缩,然后输出到 ...
- C# ASP 上传/下载文件
1. 上传文件前台页面 <div style="padding-left:20px;"> <asp:FileUpload ID="FileUpload ...
- Asp.Net 之 下载文件的常用方式
1.直接使用Response.TransmitFile(filename)方法 protected void Button_Click(object sender, EventArgs e) { /* ...
- ASP.NET 打包下载文件
使用的类库为:ICSharpCode.SharpZipLib.dll 一种是打包整个文件夹,另一种是打包指定的多个文件,大同小异: using ICSharpCode.SharpZipLib.Zip; ...
- ASP.NET 后台下载文件方法
void DownLoadFile(string fileName) { string filePath = Server.MapPath(fileName);//路径 //以字符流的形式下载文件 F ...
- asp.net core 下载文件,上传excel文件
下载文件: 代码: 后端代码: public IActionResult DownloadFile() { var FilePath = @"./files/deparment.xlsx&q ...
随机推荐
- [SQL in Azure] Configure a VNet to VNet Connection
http://msdn.microsoft.com/en-us/library/azure/dn690122.aspx Configure a VNet to VNet Connection 2 ou ...
- Android调用Webservice发送文件
一服务器端C#这里有三个上传方法1.uploadFile( byte []bs, String fileName); PC机操作是没有问题2. uploadImage(String filename, ...
- linux c编程操作数据库(sqlite3应用)
首先pThread 不是linux系统默认库,连接的时候需要使用库libpthread.a. 加入-lpthread参数.另外会有lopen什么找不到的情况.加入-ldl 指定目录.Project_ ...
- python中 staticmethod与classmethod区别
staticmethod与classmethod区别 参考 https://stackoverflow.com/questions/136097/what-is-the-difference-betw ...
- 设置Chrome忽略网站证书错误
本人在XP下使用Chrome.总是莫名其妙的提示整数错误,一部分https网站无法直接访问.网上找了下,把解决思路记录下来. 解决这个问题很简单,只需要修改你平时用来启动Chrome的快捷方式就可以忽 ...
- Leetcode:Interleaving String 解题报告
Interleaving StringGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For ...
- zmap blacklist
# From IANA IPv4 Special-Purpose Address Registry# http://www.iana.org/assignments/iana-ipv4-special ...
- [EF] 如何在 Entity Framework 中以手动方式设定 Code First 的 Migration 作业
Entity Framework (简称 EF) 发展到现在, 版本已经进入 6.1.0, 距离我写的「在 VS2013 以 Code First 方式建立 EF 资料库」这篇文章已有半年的时间.如果 ...
- Spring高级装配(一) profile
Spring高级装配要学习的内容包括: Spring profile 条件化的bean声明 自动装配与歧义性 bean的作用域 Spring表达式语言 以上属于高级一点的bean装配技术,如果你没有啥 ...
- TypeError: decoding Unicode is not supported
在试图读取网页的时候遇到TypeError: decoding Unicode is not supported, 主要原因是返回的字符串已经是unicode类型了