title: Change URL Rewrite Rule in Web.Config from Code C#
body: <p>I want to modify rewrite rule from C# code. Url Rewrite rule is resides in web.config file.
  </p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;rewrite&gt;
        &lt;rules&gt;
          &lt;rule name="partners"&gt;
            &lt;match url="^partners$" /&gt;
            &lt;action type="Rewrite"
                    url="partners.aspx" /&gt;
          &lt;/rule&gt;
          &lt;rule name="news"&gt;
            &lt;match url="^news$" /&gt;
            &lt;action type="Rewrite"
                    url="news.aspx" /&gt;
          &lt;/rule&gt;
          &lt;rule name="projects"&gt;
            &lt;match url="^projects$" /&gt;
            &lt;action type="Rewrite"
                    url="projects.aspx" /&gt;
          &lt;/rule&gt;
        &lt;/rules&gt;
      &lt;/rewrite&gt;
    &lt;/system.webServer&gt;
  </code></pre>
  
  <p>I want to change for ex. <code>&lt;rule name="partners"&gt; &lt;match url="^partners$" /&gt;</code> to <code>&lt;rule name="partners"&gt; &lt;match url="^friendship/partners$" /&gt;</code>, </p>
  
  <p>how can I find node rule and update match url to "new one" where name = "partners";?</p>
  
  <p>this is my idea for dynamic url rewriting. thanks for any other ways if you have.</p>