title: IIS Error: Unrecognized configuration path 'MACHINE/WEBROOT/APPHOST/websiteName
body: <p>I am trying to set <strong>IP Address and Domain Restrictions</strong> in the c# code, i am following <a href="https://www.iis.net/configreference/system.webserver/security/ipsecurity/add#006" rel="nofollow noreferrer">this</a> article, but it gives me unrecognized location error.</p>
  <blockquote>
  <p>Error: Unrecognized configuration path 'MACHINE/WEBROOT/APPHOST/websiteName</p>
  </blockquote>
  <p>My Code:</p>
  <pre><code>using (var serverManager = new ServerManager())
              {
                  var config = serverManager.GetApplicationHostConfiguration();
                  var ipSecuritySection = config.GetSection(&quot;system.webServer/security/ipSecurity&quot;, &quot;websiteName&quot;);
                  var ipSecurityCollection = ipSecuritySection.GetCollection();
  
                  var addElement = ipSecurityCollection.CreateElement(&quot;add&quot;);
                  addElement[&quot;ipAddress&quot;] = @&quot;SomeIP&quot;;
                  addElement[&quot;allowed&quot;] = false;
                  ipSecurityCollection.Add(addElement);
  
                  var addElement1 = ipSecurityCollection.CreateElement(&quot;add&quot;);
                  addElement1[&quot;ipAddress&quot;] = @&quot;SomeIP&quot;;
                  addElement1[&quot;subnetMask&quot;] = @&quot;255.255.0.0&quot;;
                  addElement1[&quot;allowed&quot;] = false;
                  ipSecurityCollection.Add(addElement1);
  
                  serverManager.CommitChanges();
                  
              }
  </code></pre>
  <p>It gives me error after this line:</p>
  <blockquote>
  <p>var ipSecuritySection = config.GetSection(&quot;system.webServer/security/ipSecurity&quot;, &quot;websiteName&quot;);</p>
  </blockquote>
  <p>Can any one tell what is wrong, or something that i have missed.</p>