Detecting Web.Config Authentication Mode

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

Say I have the following web.config:



    
        

        
5条回答
  •  萌比男神i
    2021-02-13 10:12

    Import the System.Web.Configuration namespace and do something like:

    var configuration = WebConfigurationManager.OpenWebConfiguration("/");
    var authenticationSection = (AuthenticationSection)configuration.GetSection("system.web/authentication");
    if (authenticationSection.Mode == AuthenticationMode.Forms)
    {
      //do something
    }
    

提交回复
热议问题