Detecting Web.Config Authentication Mode

前端 未结 5 1145
遥遥无期
遥遥无期 2021-02-13 09:39

Say I have the following web.config:



    
        

        
5条回答
  •  遥遥无期
    2021-02-13 10:08

    use an xpath query //configuration/system.web/authentication[mode] ?

    protected void Page_Load(object sender, EventArgs e)
    {
     XmlDocument config = new XmlDocument();
     config.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
     XmlNode node = config.SelectSingleNode("//configuration/system.web/authentication");
     this.Label1.Text = node.Attributes["mode"].Value;
    }
    

提交回复
热议问题