.net Access Forms authentication “timeout” value in code

后端 未结 6 1563
小蘑菇
小蘑菇 2021-02-09 18:39

I\'m adding a logout expiration alert to my application and would like to access my web.config forms authentication \"timeout\" value from my code. Any way i could do this?

6条回答
  •  时光说笑
    2021-02-09 19:27

     Configuration conn = WebConfigurationManager.OpenWebConfiguration("");
    
                AuthenticationSection section = (AuthenticationSection)conn.SectionGroups.Get("system.web").Sections.Get("authentication");
    
    
    
                long cookieExpires = System.Convert.ToInt64(section.Forms.Timeout.TotalMinutes);
    

提交回复
热议问题