I’m trying to show an image on my Image control but it isn’t working. I’m using it as a screenshot preview basically. I have the bitmap save to the Images folder in the server path, and then I set the ImageUrl for the control to that saved image location. Here is the code I have. This code executes on a button click:
img.Save(Server.MapPath("~/Images/") + "test.png", ImageFormat.Png);
Image1.ImageUrl = Server.MapPath("~/Images/") + "test.png";
Image1.DataBind();
No exceptions are caught, and the image is saving correctly in the path.
You can’t use Server.MapPath for URL’s, change to this (presuming that images folder is in the root folder of your application):
update:
As Graymatter suggested ih comments that should be :
I overlooked that we are talking about Image server control