api返回一张图片

指定客户端得到的图片名字,

比如用ie访问api,得到的是一个名叫 getimage 的文件,而不是XXX.jpg

ContentDispositionHeaderValue d = new

ContentDispositionHeaderValue("attachment");  #Inline是直接显示,attachment是附件下载

d.FileName = "123.jpg";

result.Content.Headers.ContentDisposition = d;

就可以指定文件名了

 

参考网站:

http://stackoverflow.com/questions/12467546/is-there-a-recommended-way-to-return-an-image-using-asp-net-web-api

http://social.msdn.microsoft.com/Forums/wpapps/zh-CN/974f10e6-f705-43b5-a171-698065dac2f2/mvc4-webapi

posted on 2014-05-21 17:08  qinyan20  阅读(739)  评论(0编辑  收藏  举报