0

What I am trying to deny users to access to static folder:

<location path="log4">
    <system.web>
        <authorization>
           <deny users="*"/>
        </authorization>
    </system.web>
</location> 

But this fails.

I found this Q&A for my question:

First answer is solution to my question:

<security>
  <requestFiltering>
    <hiddenSegments>
      <add segment="Uploads"/>
    </hiddenSegments>
  </requestFiltering>
</security>

That's good.

But when I look closer to my web config, I have other sections that may restrict or allow users to access folder such as images or css, but below are not considered for input requests it allows any one access them.

<location path="images">
    <system.web>
        <authorization>
            <deny users="*"/>
        </authorization>
    </system.web>
</location>
<location path="css">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>

In the same thread second most upvoted answer, I would exprect it works but not.

<?xml version="1.0"?>
<configuration>
    <system.web>
        <authorization>
            <allow roles="Administrator"/>
            <deny users="*" />              
        </authorization>
    </system.web>
</configuration>

This might be a solution to my second part of question:

<modules runAllManagedModulesForAllRequests="true"></modules>

However as noted here this cause performance issue.

Here is also mentioned set up handler for example .xml files but I need at folder level.

My question how to deny/allow access to static folder content with location path with out seting runAllManagedModulesForAllRequests to true.

My application works with form authentication and on applicaton pool .net 2.0 with integrated mode.

asdf_enel_hak
  • 7,474
  • 5
  • 42
  • 84
  • Could you tell us what is your exact requirement? – Jalpa Panchal Apr 09 '19 at 07:40
  • my requirement deny to static folder content with location path with out setting runAllManagedModulesForAllRequests to true. It seems the point is that there is a "separation" between IIS handling and asp.net handling. – asdf_enel_hak Apr 09 '19 at 07:44

1 Answers1

0

You could set deny users in web.config as below:

<location path="s3">
<system.web>
  <authorization>
    <deny users="*" />
  </authorization>
</system.web>

enter image description here

enter image description here You could also refer below article for more detail:

Setting authorization rules for a particular page or folder in web.config

Regards, Jalpa.

Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26