我的 ASP.NET 项目中包含该img
文件夹下的图像。我正在尝试自动化显示图像的过程,而无需手动添加每个图像。
我试过:
@foreach (var image in Directory.GetFiles(Server.MapPath("/img/portfolio/engagement")))
{
<li class="span3"><a href="#" class="thumbnail"><img src="@image"/></a></li>
}
这输出:
<ul class="thumbnails">
<li class="span3"><a href="#" class="thumbnail"><img src="C:\Users\Cody\Documents\CMBS\CodySolution\CodySolution\img\portfolio\engagement\IMG_0093.jpg"/></a></li>
<li class="span3"><a href="#" class="thumbnail"><img src="C:\Users\Cody\Documents\CMBS\CodySolution\CodySolution\img\portfolio\engagement\IMG_0130.jpg"/></a></li>
<li class="span3"><a href="#" class="thumbnail"><img src="C:\Users\Cody\Documents\CMBS\CodySolution\CodySolution\img\portfolio\engagement\IMG_0144.jpg"/></a></li>
<li class="span3"><a href="#" class="thumbnail"><img src="C:\Users\Cody\Documents\CMBS\CodySolution\CodySolution\img\portfolio\engagement\IMG_9931.jpg"/></a></li>
</ul>
这行不通。图片不显示,当我尝试点击直接链接时,它告诉我A potentially dangerous Request.Path value was detected from the client (:).
做我想做的事情的正确方法是什么?