1

I have a set of Images in their own folder in the root of an mvc project and these all correspond to their filenames that are listed in a database. I want to be able to load these images to the page as logo.png everytime regardless of their actual filename. I don't need it to change the filename itself, just to mask it with a temp name of logo.png, therefore staopping people from guessing other logo names in the browser URL. Is there a way to this in MVC?

Web Develop Wolf
  • 5,996
  • 12
  • 52
  • 101
  • Why even use a temp name? You could turn your images into byte arrays and just bind the tag to to the byte array directly. http://stackoverflow.com/questions/17952514/mvc-how-to-display-a-byte-array-image-from-model – Fran May 04 '16 at 14:39
  • The image isn't stored in the DB it's just a string of the filename and extension – Web Develop Wolf May 04 '16 at 14:45
  • 1
    yoiu can read the file into a byte array in your controller action. – Fran May 04 '16 at 14:46
  • I have absolutley no idea how I'd do that - have you got an example or tutorial you could point me to have a look at? Or is that what the link that you shared above is doing? – Web Develop Wolf May 04 '16 at 15:21
  • 1
    Replace the db calls that are populating the bytearray with calls to System.IO.File.ReadAllBytes("your file path") – Fran May 04 '16 at 18:10

0 Answers0