I have an image in a folder, when I try to set the ImageUrl from the behind code I get a little symbol that looks broken in half instead of the picture. If I set the ImageUrl in the Image properties it works. What am I doing wrong?
var imagepath = Server.MapPath(@"~/images/candidates/small/image.jpg");
System.Drawing.Image image = System.Drawing.Image.FromFile(imagepath);
int ActualWidth = image.Width;
int ActualHeight = image.Height;
candImage.ImageUrl = imagepath;
candImage.Height = ActualHeight;
The
ImageUrlshould be the URL to the image, as you would get it from a browser, not its location on the hard drive, which is whatServer.MapPathreturns.You should be using: