我正在尝试使用网络上的IP地址从其他服务器检索图像,但无法在我的Web应用程序中获取图像。
我尝试了以下方法来写入图像路径,但无法获取图像:
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" />
请注意,图像位于Windows资源管理器中可以正常打开的共享文件夹中
请帮助我解决这个问题
我经历了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;" />
我仍然无法获取图像,请帮助我写路径