如何在Url.Content中显示图像? [英] How to display images in a Url.Content?

查看:37
本文介绍了如何在Url.Content中显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我的代码中有一些问题首先我要显示目录子目录中的图像

这是我的代码



@foreach(Directory.GetDirectories中的字符串折叠(Server.MapPath(〜/ Content / Uploads)))

{

string folder = fold.Substring( fold.LastIndexOf(\\)+ 1);



string path =〜/ Content / Uploads /;



字符串路径= Path.Combine(路径,文件夹);



string [] fo = Directory.GetFiles(Server.MapPath(路径));



foreach(字符串表示)

{

img src =@ Url .Content(fol)width =20%/>



}



}

但是当我运行应用程序时

输出是一个文本

输出

c:\ usersrs \ brian \documents\visual studio 2012 \Projects\ImagesSample\ImagesSample\Content\ Up loads\Brochure 1 \ Brochure 1.png

而不是图片?

你能帮帮我吗?

先谢谢!

Hello I Have some Issues in my code First I want to display the images from the subdirectory of a directory
this is my code

@foreach (string fold in Directory.GetDirectories(Server.MapPath("~/Content/Uploads")))
{
string folder = fold.Substring(fold.LastIndexOf("\\")+1);

string path = "~/Content/Uploads/";

string paths = Path.Combine(path, folder);

string[] fo = Directory.GetFiles(Server.MapPath(paths));

foreach (string fol in fo)
{
img src ="@Url.Content(fol)" width="20%"/>

}

}
but when I run The Application
The Output is a text
Output
c:\users\brian\documents\visual studio 2012\Projects\ImagesSample\ImagesSample\Content\Uploads\Brochure 1\Brochure 1.png
instead of a Images?
Can you help Me Out here?
Thanks In advance!

推荐答案

这篇文章可以帮到你 - MVC。返回在控制器中动态绘制的图像。 [ ^ ]。
This post could help you - MVC. Return image dynamically drawn in controller.[^].


这篇关于如何在Url.Content中显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆