I am trying to restrict users(except admin) to access my folder images. For example the path is:
~/content/images/coverBeg.jpg
If the use
It's because static content, like images, are served directly by IIS, not involving MVC pipeline. To change that, you can do the following:
add
<modules runAllManagedModulesForAllRequests="true">
to <system.webServer>
section of site's web.config. It will run MVC pipeline for every request, including static files - like css, js and images.
Then your config from above will work (I mean your 2nd approach).