0

I'm new to mvc3 and what I'm trying to do is show in a view the images that are saved in the file system under C:\temp

In my project I defined a resource, photo_url -> C:\temp, I pass to the view through ViewData, at the end I can get the complete and correct path of the file I want to display, example ... src = "C:\temp\img.jpg" ... but I get the error "Not allowed to load local resource:"

src="@Url.Content(ViewData["path_photo"] + "\\" + item.link_photo)

By putting the photos inside the project, for example in ..\..\content\photo, I can visualize them, but saving them outside the project I can't access them. Help! Thank you.

  • Are the images you're trying to show in C:\temp on the web server or on the browser's local hard drive? I'm assuming the image you're trying to show is on the web server, but src="C:\temp\img.jpg" in the HTML on the browser is trying to look on the browser's computer. You'll need to either make the images on the web server available via an endpoint, or - you can build an image handler where the web server reads the file from C:\temp and then streams the bits down to the browser. Take a look at https://stackoverflow.com/questions/4027970/image-handler-on-mvc – jefftrotman Jul 17 '19 at 18:48
  • Thanks for the reply, I work locally, I launch my application via visual studio in debug – Luca Vasapolli Jul 18 '19 at 07:11

0 Answers0