loading ...
loading...

2008-01-09 | 动态生成WEB子目录的Web.Config

分享
标签: asp.net  2.0  Web.Config 

            XmlDocument doc = new XmlDocument();
            doc.Load(webDiskPath + "Web.Config");
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            nsmgr.AddNamespace("ab", "http://schemas.microsoft.com/.NetConfiguration/v2.0");
            XmlNode xn = doc.SelectSingleNode("//ab:configuration/ab:system.web/ab:authorization",nsmgr);
            XmlElement xe = doc.CreateElement("","allow","http://schemas.microsoft.com/.NetConfiguration/v2.0");
            xe.SetAttribute("users", theUserName);
            xn.AppendChild(xe);

            xe = doc.CreateElement("", "deny", "http://schemas.microsoft.com/.NetConfiguration/v2.0");
            xe.SetAttribute("users", "*");
            xn.AppendChild(xe);

            doc.Save(userWebDiskPath + "\\Web.Config");

分享 分享 |  评论 (0) |  阅读 (?)  |  固定链接 |  类别 (ASP.NET之旅) |  发表于 22:13
搜狐博客温馨提示:搜狐博客官方不会要求参加活动的各位博友缴纳任何的手续费用。请勿轻信留言、评论中的中奖信息,更不要拨打陌生电话及向陌生帐户汇款,谨防受骗!识别更多网络骗术,请 点击查看详情
您还未登录,只能匿名发表评论。或者您可以 登录 后发表。
 
  *中国人爱国心,搜狗输入法爱国主题皮肤下载>>
表  情:
加载中...
回复通知: 同时用小纸条通知对方该回复