skaleem1
asked on
Images not loading in ASP.NET app on my local machine
I have a web app developed using ASP.NET, C# and javascript that speaks to SQL Sever in the back end. I have a web page that loads images for a specific product based on the image file path stored in one of the database table column as follows:
C:\Photos\HDK-24567-003 (1200 Paper, Dark Blue)[HB]-1.jpg
The Photos folder is residing on the same server where the App is deployed to and running on and the images are correctly loaded in the deployed web app. I made sure that the same folder (C:\Photos\) is created on my local machine on C: drive so that I can load those images while running the app on my local machine using Visual Studio. However, the images do not load at all. I made sure that the folder is shared and is accessible to the app (full control). What can be the reason? See the code section to show how am I loading those images:
C:\Photos\HDK-24567-003 (1200 Paper, Dark Blue)[HB]-1.jpg
The Photos folder is residing on the same server where the App is deployed to and running on and the images are correctly loaded in the deployed web app. I made sure that the same folder (C:\Photos\) is created on my local machine on C: drive so that I can load those images while running the app on my local machine using Visual Studio. However, the images do not load at all. I made sure that the folder is shared and is accessible to the app (full control). What can be the reason? See the code section to show how am I loading those images:
private void DisplayAllPartImages()
{
//we retrieve data only if it is not in the session or a part is deleted
if ((Session["dsPartPhotos"] == null) || (HProcessFileDelete.Value == "true"))
{
LoadData();
}
if(Session["dsPartPhotos"] !=null)
dsPartPhotos = (DataSet)Session["dsPartPhotos"];
if (dsPartPhotos == null)
return;
string imageName=string.Empty;
string imageNameCopy = string.Empty;
string imageSrc = "";
string imageURL = "";
for (int i = 0; i < dsPartPhotos.Tables[IMAGES].Rows.Count; i++)
{
Panel oPanel = new Panel();
Image oImage = new Image();
oImage.CssClass = "ImageBorderStyleColor";
oPanel.Width = 97;
oPanel.Height = 97;
oPanel.CssClass = "BorderStyleColor";
oPanel.BorderStyle = System.Web.UI.WebControls.BorderStyle.Ridge;
oImage.ID = dsPartPhotos.Tables[IMAGES].Rows[i]["HWDetailsID"].ToString();
oPanel.CssClass = "BorderStyleColor";
Session["ImageWidth"] = 500;
Session["ImageHeight"] = 500;
imageURL = string.Format("~/PicHandler.ashx?&Src={0}&ImgId={1}&CallingSource={2}&maxHeight={3}&maxWidth={4}", "HWDetails", dsPartPhotos.Tables[IMAGES].Rows[i]["HWDetailsID"].ToString(), "EnlargedImage", Session["ImageWidth"], Session["ImageHeight"]);
if (i == 0)
{
ImageRightPane.ImageUrl = imageURL;
ImageRightPane.ToolTip = ImageRightPane.ImageUrl;
}
imageSrc = ResolveClientUrl(imageURL);
oPanel.ID = "Panel" + i.ToString();
//Change the currently clicked panel border color to blue
oPanel.Attributes.Add("onclick", "javascript:ctl00_ContentPlaceHolder1_" + oPanel.ClientID + ".className='MouseOverBorderStyle';" + ImageRightPane.ClientID + ".src='" + imageSrc + "'");
oPanel.Attributes.Add("onclick", "SetValue('" + "ctl00_ContentPlaceHolder1_" + oPanel.ClientID + "', " + "'" + dsPartPhotos.Tables[IMAGES].Rows[i]["HWDetailsID"].ToString() + "', " + "'" + dsPartPhotos.Tables[IMAGES].Rows[i]["PhotoFileName"].ToString() + "');" + ImageRightPane.ClientID + ".src='" + imageSrc + "'");
oImage.ImageUrl = string.Format("~/PicHandler.ashx?Src={0}&ImgId={1}&CallingSource={2}&maxHeight={3}&maxWidth={4}", "HWDetails", dsPartPhotos.Tables[IMAGES].Rows[i]["HWDetailsID"].ToString(), "ThumbnailSize", 95, 95);
if (i == 0)
{
oPanel.CssClass = "MouseOverBorderStyle";
}
oPanel.Controls.Add(oImage);
this.DivPhotoList.Controls.Add(oPanel);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The space was the issue and the space in the file name was interpreted as underscore(_) somehow. I fixed the importer and it works like a charm now.
Thanks for the hint
Thanks for the hint
imageURL = string.Format("~/PicHandle
check if PickHandler.ashx is correctly registered in your Config
or post the Pichandler.ashx reference code