3

私は Owin パイプラインを使用しており、startup.auth.cs でアプリケーションの Cookie 間隔を以下のように設定しています timeout=Convert.ToDouble(ConfigurationManager.AppSettings["SessionTimeOut"]);

           // Owin Middleware3 - Cookie Authentication Middleware

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                LoginPath = new PathString("/Account/Login"),
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                ExpireTimeSpan = TimeSpan.FromMinutes(timeout),
                SlidingExpiration = true

                }
            });

web.config で SessionTimeout の値を変更すると、IIS を再起動して新しい値を取得する必要があります。startup.auth.cs は初回のみ呼び出されるためです。とにかく、IIS を再起動せずに Cookie の有効期限を動的に変更できますか。また、startup.auth.cs で構成するシングル サインオンに kento.authservices を使用しています。これの構成値も動的に変更する必要があります。これについて助けてください。

4

1 に答える 1

0

新しいオブジェクト CookieAuthenticationOptions を UseCookieAuthentication に渡すのではなく、参照を保持してその参照を渡すことができます。これにより、変更時に ExpireTimeSpan を設定できるようになります。

CookieAuthenticationOptions Co = new CookieAuthenticationOptions();

そして、値が変更されたときにコードで Co.ExpireTimeSpan を設定します。

于 2016-09-19T20:45:29.703 に答える