Asp.net mvc restrict specific users to access folder content

后端 未结 1 884
自闭症患者
自闭症患者 2021-01-06 18:32

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

相关标签:
1条回答
  • 2021-01-06 18:51

    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).

    0 讨论(0)
提交回复
热议问题