Hi yes, it is possible to display it from the App_Data Folder.
In order to display the image, you have to convert it to base64string.
<pre>
public string ReturnImage()
{
string imageYouWantToDisplay = "Test.png";
string base64String = "";
String path = HostingEnvironment.MapPath("~/App_Data");
alternatively if you wanted to pass a param.
so for example
int WhatEverId = 5
~/App_Data/YourFolder/5/imageYouWantToDisplay
your path will then look like this.
String folderPath = HostingEnvironment.MapPath("~/App_Data/YourFolder") + @"\" + WhatEverId.ToString();
using (Image image = Image.FromFile(path + "/" + imageYouWantToDisplay))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();
base64String = Convert.ToBase64String(imageBytes);
}
}
return base64String;
}
you can then call that in an action method
public DisplayImages (){
List<WhateverModel> test = new List<WhateverModel>();
test = GetAll().ToList();
test.ForEach(x=> { MyImage = ReturnImage();});
return test;
}
@model WhateverModel
<pre> <img src="@MyImage" />
javascript
<pre> <img src="${MyImage}" />