I store my image files in my App_Data/img folder and store the name of each image file in my database table. I access the DB through Entity Framework. My initial idea was getting the name of image file from DB, creating an image path string and then assigning that string to the "src" attribute of an element. But it just didn't work. Nothing displayed. I have gone through various suggestions but none worked for me. The following was the most refined one but it did'nt work either
<img src="~/App_Data/img/@Url.Content(Model.ImagePath)" height=100 width=200 />
Here, it seems that tilde doesn't work. Becasue in the page source, my path is rendered as written not as a relative path to the root folder of my app.
1) How can I solve that path issue? Why does not tilde help me to point to my root folder?
2) Is that a good way to implement such a task? As far as I searched, many people address base64 string stuff. With a static / predefined file path, base64 conversion worked for me as well. But I could'nt manage to work with base64 stuff when I dynamically change the file to be shown. Therefore, I gave up using it. However, I'm not sure that if that's a good idea?