once i click button, my image1 will display an image;
when i set my imagePath to
Server.MapPath("~/SME IMAGE/anonymous_avatar.gif");
my url not work
but when i set my path to
"~/SME IMAGE/anonymous_avatar.gif"
my url work
so basically what happen to my Server.MapPath?
try
{
string imagePath = Server.MapPath("~/SME IMAGE/anonymous_avatar.gif");
Image1.ImageUrl = imagePath;
Response.Write("success");
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
Server.MapPathit translates the “web” path into your local path.So
Server.MapPath("Server.MapPath")it will give the local location of your file.You are assigning this to the
ImageUrlproperty, but this will be translated to something like"www.mywebsite.com/C:\wwwroot\somefile.gif"