<ipSecurity> in web.config

Martin Stabrey 1 Reputation point
2021-10-15T11:41:32.77+00:00

We're wanting to restrict access to a folder called "unicol" on our web site. Only one IP address should be able to access this folder.
Will the below web.config on the root folder of our web site do the trick? Is there anything that we need to add or leave out?

Thank you.

Mart

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <defaultDocument>
            <files>
                <clear />
                <add value="default.aspx" />
            </files>
        </defaultDocument>
        <httpErrors errorMode="DetailedLocalOnly" existingResponse="Auto" />
    </system.webServer>

  <location path="unicol">
    <system.webServer>
      <security>
        <ipSecurity allowUnlisted="false">
          <clear />
          <add ipAddress="xx.xx.xx.xx" allowed="true" />
        </ipSecurity>
      </security>
   </system.webServer>
  </location> 

</configuration>
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,254 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,066 Reputation points
    2021-10-18T06:35:16.91+00:00

    Hi @Martin Stabrey ,
    As far as I think,you need create a new web.config file in your unicol file instead of the root folder.

    Best regards,
    Yijing Sun


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Martin Stabrey 1 Reputation point
    2021-10-19T07:55:07.88+00:00

    Thank you. That makes sense. We have removed those sections.

    We now have added this very basic web.config to the folder in question:

    <?xml version="1.0"?>
    <configuration>

     <system.webServer>  
       <security>  
         <ipSecurity allowUnlisted="false">  
           <clear />  
           <add ipAddress="102.182.255.11" allowed="true" />  
         </ipSecurity>  
       </security>  
    </system.webServer>  
      
    

    </configuration>

    Why would we be receiving the 500.19 error. Is it something to do with 141675-screenshot-2021-10-19-095311.jpgthe configuration of the server at our web presence provider?


  3. Martin Stabrey 1 Reputation point
    2021-10-21T07:16:04.783+00:00

    Thank you for your time. Appreciated!