我有一个包含 aspImage 控件的网页当我通过图像处理程序从数据库中检索图像时,我可以在 aspImage 控件中显示该图像!但 。. . 问题是当我右键单击图像并单击“将图片另存为”时,我收到此错误消息:正在保存或检索的文件类型已被阻止!我想知道这是 IE 问题还是我的代码有问题?!有什么帮助吗?!
这是我的图像处理程序代码:
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Web;
public class Handler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString);
public void ProcessRequest(HttpContext context)
{
string TableName=context.Session["TableToQuery"].ToString();
string ID=context.Session["ID"].ToString();
SqlCommand comm = new SqlCommand("SELECT * FROM "+ TableName +" WHERE ID=" + ID, conn);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
dr.Read();
context.Response.BinaryWrite((byte[])dr["Image"]);
conn.Close();
}
public bool IsReusable
{
get
{
return false;
}
}
}
这是我显示图像的数据列表:
<asp:DataList ID="DL" runat="server" Width="100%" Height="100%" RepeatColumns="1"
RepeatDirection="Vertical">
<ItemTemplate>
<table style="height: 100%; width: 100%">
<tr style="width: 100%; height: 350px">
<td valign="middle">
<asp:Image ID="IMage" runat="server" ImageUrl='<%# "Handler.ashx?ID=" + Eval("ID") %>' />
</td>
</tr>
<tr style="width: 100%; height: 250px">
<td valign="top">
<asp:TextBox ID="txtDecoded" runat="server" TextMode="MultiLine" Width="316px"
Height="200px" Text='<%#Eval("DecodedString")%>'></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>