Search code examples
asp.netasp.net-mvciisasp.net-mvc-5architecture

how to serve image from custom folder?


I have this site deployed in IIS: enter image description here

Now what I am trying to do is to show an image under the App_Data folder, the path being "App_Data/uploads/abc.jpg" In code I have this:

<img src="~/App_Data/uploads/abc.jpg" alt="img">

and then I get a 404 error suggesting resource not found. When I inspected the sources tab in chrome dev tools I have this : enter image description here

This means the App_Data folder was not even served in the request in the first place now how could I serve the folder, the folder contains images of my products. Also if someone could suggest if this is a good approach since there would be thousands of product images and I don't necessarily need to serve the entire folder for each request there has to be a better way, Thanks


Solution

  • In the iis request filtering, the app_data folder cannot be accessed, so I suggest creating a new folder and uploading image to this folder.

    enter image description here