Hi
when i am get the image from database by using Handler here i have a small Problem
In Local this code is executed successfully but when that code is uploaded in hostgator server I am getting The
"Failed to load the Given Url"
The ASPX Code
<asp:DataList ID="DataList1" runat="server"
RepeatColumns="3" RepeatDirection="Horizontal">
<ItemTemplate>
<table>
<tr>
<td valign="middle" align="center" style="background-color:#cccccc;border:1px solid gray;width:150px;height:150px;"><%#DataBinder.Eval(Container.DataItem, "images") %></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
The ASPX.CS Code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindDataList();
}
private void BindDataList()
{
string sqlCmd = "SELECT carprofile FROM ca";
DataBaseHelper DBHelper = new DataBaseHelper();
DataTable dt = DBHelper.GetTable(sqlCmd);
DataColumn imageCol = new DataColumn("images", typeof(string));
dt.Columns.Add(imageCol);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i][imageCol] = string.Format("<img src='Handler.ashx?id={0}' alt='' style='width:100px' />", dt.Rows[i][0].ToString());
}
}
DataList1.DataSource = dt;
DataList1.DataBind();
}
Handler code
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
HttpRequest request = context.Request;
if (!string.IsNullOrEmpty(request.QueryString["id"]))
{
Hashtable hash = new Hashtable();
hash.Add("@carprofile", request.QueryString["id"]);
DataBaseHelper DBHelper = new DataBaseHelper();
byte[] imageByte = (byte[])DBHelper.SQLExecuteNonQuery("Get_images", hash);
if (imageByte != null && imageByte.Length > 0)
{
context.Response.ContentType = "image/jpeg";
context.Response.BinaryWrite(imageByte);
}
}
}
public bool IsReusable {
get {
return false;
}
}
}
Plzzz Give me the Solution for this
Thank you