0

I have a back office which I uploaded images with. I upload them to

d:\images\

Then i have a front end application that is supposed to display these images.

one of the image i have is and obviously I cant display d:\images\foo.jpg in the html.

what the best practice to work with images and paths that is shared between different applications?

DarthVader
  • 52,984
  • 76
  • 209
  • 300
  • 1
    This is what I have done in the past -- http://stackoverflow.com/questions/186062/can-an-asp-net-mvc-controller-return-an-image – John Kalberer Apr 18 '12 at 18:36

2 Answers2

1

You could map a virtual folder in each IIS site to the shared location. I would develop a set of rules for folder structure first, but you can then access the files directly through IIS rather than write code to do it.

mgnoonan
  • 7,060
  • 5
  • 24
  • 27
0

How about creating a handler or a controller which will return you the image in the response.

public ActionResult LoadImage(string name)
{

    string imageBasePath = "[GET FROM CONFIG]";
string fullPath = imageBasePath + name;

    return base.File(fullPath, "image/jpg");
}

UPDATE I agree with mgnoonan, if you can work out to map the directory in IIS that is much better than writing and handling the code. If that's not the option for you then the suggested code should work

Kunal
  • 1,913
  • 6
  • 29
  • 45