i want to delete location path using parameter textbox and allow user ..
example :
location path = textbox1
allow user = textbox2
explanation : i enter name of location path in the texbox1 and allow user in the texbox2, when i click button delete then location path based on parameter textbox1 and textbox2 in web config will be remove..
this below my web config
<location path="3pm.aspx">
<system.web>
<authorization>
<allow users="testing1,testing2,tunggal ,usertest" />
<deny users="*" />
</authorization>
</system.web>
</location>
so far this is my code for deleting location path using parameter name of path , yet to parameter allow user ..
protected void DeleteLocationPath(object sender, EventArgs e)
{
string path = Server.MapPath("~/Web.Config");
XmlDocument xDoc = new XmlDocument();
xDoc.Load(path);
XmlNodeList list = xDoc.DocumentElement.SelectNodes("location");
if (list.Count > 0)
{
foreach (XmlNode node in list)
{
if (node.Attributes["path"].Value == this.txtLocation.Text.Trim())
{
node.ParentNode.RemoveChild(node);
XmlTextWriter xwriter = new XmlTextWriter(path, null);
xDoc.WriteTo(xwriter);
xwriter.Close();
break;
}
}
}
}