日期:2014-05-17 浏览次数:20498 次
<asp:Image runat="server" ImageUrl='<%# GetUrl((string)Eval("img_num")) %>' />
protected string GetUrl(string imageId)
{
return ResolveUrl("~/DownloadImage.ashx?id="+imageId);
}
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var name = context.Request.QueryString["id"];
var path = context.Server.MapPath("~/app_data/pics/" + name + ".jpg");
context.Response.TransmitFile(path);
}
public bool IsReusable
{
get
{
return false;
}
}
}