ASP.NET Return image from .aspx link

2020-02-01 01:01发布

Is it possible to output an image (or any file type) to a download link when a user clicks on a link from another ASP.NET page?

I have the file name and byte[].

<a href="getfile.aspx?id=1">Get File</a>

...where getfile returns the file instead of going to the getfile.aspx page.

标签: asp.net
7条回答
对你真心纯属浪费
2楼-- · 2020-02-01 02:02

How to Create Text Image on the fly with ASP.NET

Something like this:

string Path = Server.MapPath(Request.ApplicationPath + "\image.jpg");
Bitmap bmp = CreateThumbnail(Path,Size,Size);
Response.ContentType = "image/jpeg";
bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
查看更多
登录 后发表回答