I am trying to retrieve an image from the other server using IP Address which is over the network but Unable to get the image in my web app.
I've tried the following ways to write the image path but unable to get the image:
C#:
string imagePath = @"http://192.168.10.245/Shared/1.jpg";
OR
string imagePath = @"file://192.168.10.245/Shared/1.jpg";
OR
string imagePath = @"\\192.168.10.245\Shared\1.jpg";
OR
string imagePath = @"192.168.10.245/Shared/1.jpg";
emp_img.ImageUrl = imagePath;
aspx:
<asp:Image runat="server" ID="emp_img" CssClass="imgstyle" />
kindly note that the image is placed in a Shared Folder which is opening fine in Windows Explorer
kindly help me resolve this
I've gone through this
Thanks
UPDATE:
I've created an Image Handler to achieve this:
ImgHandler.ashx:
public class ImgHandler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "image/jpg";
string EmpCode = context.Request.Params["EmpCode"].ToString();
string path = "//192.168.10.245\\Shared\\"+EmpCode+".jpg";
context.Response.WriteFile(path);
}
public bool IsReusable {
get {
return false;
}
}
}
aspx:
<img src="ImgHandler.ashx?EmpCode=1" style="max-width:250px; max-height:250px;" />
I'm still unable to get the image, kindly help me writting the path