图像未在MVC视图中显示

时间:2015-08-03 11:15:55

标签: image asp.net-mvc-4 foreach viewbag

我正在尝试将文件夹中的所有图像显示到我的视图中。 但是图片没有加载到我的视图中 这是我的控制器代码。

  string directory1 = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\MogasImages\\";
  ViewBag.Images = Directory.EnumerateFiles(directory1)
                            .Select(fn => directory1 + Path.GetFileName(fn));
   return View();

这是我的查看代码(.cshtml)

@foreach(var image in (IEnumerable<string>)ViewBag.Images)
 {
   <label>Hello</label>

   <img src="@Url.Content(image)" alt="Hejsan" />
 }

这是我的ViewBag图像源 &#34; C:\用户\ karthik.mushyam \应用程序数据\漫游\ MogasImages \ 2b0ac2b0-933a-4737-bbb4-a47d25224a4f.Jpeg&#34;

像这样我在Quickwatch和循环中看到了4张图像但是图像没有显示在视图中我有4个图像循环重复4次标签正在加载。

希望最好......

0 个答案:

没有答案