0

I want display image in my View. But file isn't found, file exist.

 string file = Server.MapPath("~") + @"/App_Data/Plakaty/" + wyd.WydarzenieId.ToString() + ".jpg";
 ViewBag.file_exist = System.IO.File.Exists(file);

I try: (Is display only alt:)

  @if (ViewBag.file_exist == true) // it's TRUE
        {
            <img src="../../App_Data/Plakaty/1029.jpg" alt="p" />
            <img src="~/App_Data/Plakaty/1029.jpg" alt="p1" />
            <img src="@Url.Content("~/App_Data/Plakaty/1029.jpg")"  alt="image"/>
            <img src="@Url.Content("../../App_Data/Plakaty/1029.jpg")"  alt="image2"/>

        }
user1031034
  • 836
  • 1
  • 14
  • 38

1 Answers1

0
<img src="../../App_Data/Plakaty/1029.jpg" alt="p" />

Taking this as example, is App_Data really in the path for the image to the outside world? Sometimes internal paths are different.

SPRBRN
  • 2,406
  • 4
  • 35
  • 48