Detecting Web.Config Authentication Mode

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

Say I have the following web.config:



    
        

        
5条回答
  •  鱼传尺愫
    2021-02-13 09:59

    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
    }
    

提交回复
热议问题