Detecting Web.Config Authentication Mode

前端 未结 5 1311
故里飘歌
故里飘歌 2021-02-13 09:15

Say I have the following web.config:



    
        

        
5条回答
  •  时光说笑
    2021-02-13 10:20

    You can also get the authentication mode by using the static ConfigurationManager class to get the section and then the enum AuthenticationMode.

    AuthenticationMode authMode = ((AuthenticationSection) ConfigurationManager.GetSection("system.web/authentication")).Mode;
    

    The difference between WebConfigurationManager and ConfigurationManager


    If you want to retrieve the name of the constant in the specified enumeration you can do this by using the Enum.GetName(Type, Object) method

    Enum.GetName(typeof(AuthenticationMode), authMode); // e.g. "Windows"
    

提交回复
热议问题