0
votes

I´m working on an application that uploads some images, then show them.

The images are store in a structure similar to this:

\App_Data\files\0d10e5c1-13ad-4493-97e7-dc4b09dc15e1\2012\3\4

As you can see, the files are segmented by companyID (the Guid), year, month and day.

The problem is when I want to show the image, I get an error “access to the path is denied” The funny thing is that the images can upload without any problems. I tried whatever combination of permission you can imagine on the folders and still nothing.

This is driving me crazy! Any ideas?

A little extra info:

The App is ASP.NET MVC 3 Project and the IIS is 7.5

I’m showing the image using a controller like this:

    [HttpGet]
    public ActionResult show(Guid id)
    {
        var results = productImagesRepository.showProductImage(id);
        return File(results.imageNameAndPath, results.contentType);
    }

Researching, I found this:

asp.net mvc app_data folder

So I tried creating a new forlder outside the APP_DATA but the results are the same.

2
Can you give an example of results.imageNameAndPath value? - Igor S.
results.imageNameAndPath = "D:\\Development\\projects\\theProject\\source\\tdbCore\_FileStore\\Files\\0d10e5c1-13ad-4493-97e7-dc4b09dc15e1\\2012\\3\\5\\20d20d84-76de-4193-98ab-f18189cfec6d - epaulk

2 Answers

2
votes

The App_Data folder is designated as a folder to store databases for your website. IIS protects this directory - and for security purposes will not serve read requests.

So - you should not store images in this folder, only database files.

0
votes

Are you sure after uploading the files you're correctly closing and disposing? IIS could be maintaining a file lock of you're not doing so. Just a guess as I cannot see your upload or other code relating to the files.

A possible quick way to check is to bounce IIS which will release all file locks, if you can then view them this would point towards a file locking problem.