.net Access Forms authentication “timeout” value in code

后端 未结 6 1585
小蘑菇
小蘑菇 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:37

    I think you can read it from the FormsAuthentication static class methods, which would be better than doing it by reading the web.config directly as you may be inheriting authentication settings from a higher level web.config.

    var authTicket = new FormsAuthenticationTicket(user.EmailAddress, true, (int)FormsAuthentication.Timeout.TotalMinutes);
    

提交回复
热议问题