2016-09-16 2 views
1

Owin 파이프 라인을 사용하고 startup.auth.cs에서 응용 프로그램 쿠키 간격을 다음과 같이 설정합니다. timeout = Convert.ToDouble (ConfigurationManager.AppSettings [ "SessionTimeOut"]); 내가의 Web.config의 경우 SessionTimeout의 값을 변경하면Owin 구성 값을 동적으로 변경합니다.

  // Owin Middleware3 - Cookie Authentication Middleware 

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

       } 
      }); 

나는 startup.auth.cs 만 처음으로 불리는 IIS 그가 새 값 t를 취할 다시 시작해야합니다. IIS를 다시 시작하지 않고도 쿠키 만료 시간을 동적으로 변경할 수 있습니까? 또한 startup.auth.cs에서 단일 사인온을 설정하기 위해 kento.authservices를 사용하고 있습니다. 이 설정 값을 동적으로 변경해야합니다. 제발 도와주세요.

+0

나는 아무것도하지 않고 웹 응용 프로그램 풀을 다시 시작하는 web.config를 변경할 때 IIS를 다시 시작할 필요가 없다고 생각합니다. –

+0

감사합니다. 그러나 startup.auth.cs의 일부 구성 값은 데이터베이스에서 가져옵니다. startup.auth.cs에서 응용 프로그램이 시작되면 값은 데이터베이스에서 가져옵니다. 그러나 사용자가 로그인 한 후에는 관리자 페이지를 통해 데이터베이스에서이 값이 변경되고 사용자가 로그 아웃 한 후 다시 시작하면 새로운 변경된 값이 발생해야하지만 startup.auth.cs는 처음 응용 프로그램이 시작됩니다. 이러한 값을 어떻게 동적으로 변경할 수 있습니까? – VVR147493

답변

0

새로운 개체 CookieAuthenticationOptions를 UseCookieAuthentication에 전달하는 대신 참조를 유지하고 참조를 전달할 수 있습니다. 그러면 변경 될 때 ExpireTimeSpan을 설정할 수 있습니다.

CookieAuthenticationOptions Co = new CookieAuthenticationOptions();

그리고 값이 변경되면 코드에 Co.ExpireTimeSpan을 설정하십시오.

+0

감사합니다. Abhishek. 참조 용으로 동일한 링크 나 예제를 제공해주십시오. – VVR147493

+0

귀하의 경우 다음과 같이 변경할 수 있습니다 : CookieAuthenticationOptions co = new CookieAuthenticationOptions (new PathString ("/ Account/Login"), DefaultAuthenticationTypes.ApplicationCookie, TimeSpan.FromMinutes (timeout), true); app.UseCookieAuthentication (co); 그런 다음 새 값이 데이터베이스에서 검색되면 co.ExpiresTimeSpan에 할당 할 수 있습니다. - Co.ExpiresTimeSpan = <데이터베이스의 새 값> 이제 참조 집합을 통해 CookieAuthenticationOptions 객체의 ExpiresTImeSpan 값에 액세스 할 수 있습니다. – abhishek58g

+0

Thanks Abhishek. 하지만 다른 페이지에서 만료 시간을 검색하고 있습니다. 이 페이지에서 (IAppbuilder) 앱은 새로운 쿠키 인증 옵션을 할당하기 위해 사용할 수 없습니다. – VVR147493

관련 문제