MVC4 WebAPI中如何返回一张图片

    public HttpResponseMessage Get(string imageName, int width, int height)
    {
        Image img = GetImage(imageName, width, height);
        MemoryStream ms = new MemoryStream();
        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
        result.Content = new ByteArrayContent(ms.ToArray());
        result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
        return result;
    }

MVC4 WebAPI中如何返回一张图片?

MVC4 WebAPI中如何返回一张图片

上一篇:百度地图API 快速上手实例 !!!


下一篇:1.No active profile set, falling back to default profiles: default