0

Before everyone marks this as duplicate, I did follow these suggestions: CSS images not showing in ASP.NET MVC Images Not Showing in MVC and several others.

This is my code:

     <img src="~/App_Data/complogo.jpg" class="rounded float-right" alt="complogo">

Which works in asp.net, but not in a MVC project. The jpg is located in the folder App_Data in the project folder. I tried changing the type of image, but not one image works. When running the project I get that 'broken' image and when hovering the mouse over it tells me 'complogo' as the alt name. I also went into F12 on Chrome, and it says 404 not found. So what am I doing wrong here ?

fl13
  • 57
  • 1
  • 1
  • 12
  • 2
    By default, IIS considers `App_Data` as "Hidden Segment". You should not store assets that needs to be available to the client in this folder. – haim770 Aug 18 '20 at 14:00
  • Thanks, I can't mark you as an answer though. – fl13 Aug 18 '20 at 14:06

1 Answers1

2

As explained in this answer the App_Data folder is special and images etc.. in this folder will not be rendered.

Add a separate folder like /Content/Images/ or just /Images to your project and serve your images from there.

CobyC
  • 2,058
  • 1
  • 18
  • 24