<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        string fileName = Server.MapPath("web.config");
        XmlDocument xDoc = new XmlDocument();
        xDoc.Load(fileName);

        XmlElement newLocationNode = xDoc.CreateElement("location");
        newLocationNode.SetAttribute("path", "default2.aspx");
        xDoc.DocumentElement.AppendChild(newLocationNode);

        XmlElement inwebNode = xDoc.CreateElement("system.web");
        newLocationNode.PrependChild(inwebNode);

        XmlElement inauthorizationNode = xDoc.CreateElement("authorization");
        inwebNode.PrependChild(inauthorizationNode);

        XmlElement inallowNode = xDoc.CreateElement("allow");
        inallowNode.SetAttribute("roles", "common users");
        inauthorizationNode.PrependChild(inallowNode);

        XmlElement indenyNode = xDoc.CreateElement("deny");
        indenyNode.SetAttribute("users", "user1,user2");
        inauthorizationNode.AppendChild(indenyNode);

        xDoc.Save(fileName);

        Response.Write("updated");
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form >
    <div>
   
    </div>
    </form>
</body>
</html>

相关文章:

  • 2021-12-06
  • 2021-06-24
  • 2021-10-21
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2020-05-10
  • 2021-12-10
  • 2022-12-23
相关资源
相似解决方案