0

Images paths are stored in sql database and images are stored in a folder "Albums" on server. I want to display those images using this code: Image1.ImageUrl = Server.MapPath("/Albums/13/9622d79b-a6b3-4354-ae14-2fbd5f986c5425db"); but this is not working. I have searched alot but couldn't find any solution. so please help me. I am using C# in visual studio

4

2 回答 2

0

您不需要 server.mappath,您只需要使用服务器上图像的绝对路径,这就是您所拥有的(没有 server.mappath)。

于 2012-10-12T06:30:34.470 回答
0

Server.MapPath 返回给定资源的物理目录。所以用 MapPath 分配图像的路径。还要确保图像文件的扩展名正确。否则服务器将返回 HTTP 404。

Image1.ImageUrl = "/Albums/13/9622d79b-a6b3-4354-ae14-2fbd5f986c5425db.jpg";

在上面的代码中,/ at start 表示服务器的根目录。因此假设“相册”是位于服务器根目录内的文件夹。

于 2012-10-12T06:33:02.480 回答