2016-12-19 55 views
0

爲了測試目的,我已將空閒超時設置爲1分鐘。另外,我有一個SessionState超時設置爲3分鐘。 SessionState超時正常工作,但IIS空閒超時不起作用?IIS空閒超時不起作用

爲了您的信息,我檢查了文件對ApplicationHost.config,已經有基於您的評論

<system.applicationHost> 
    <applicationPools> 
     <add name="dev_web_core" autoStart="true" startMode="AlwaysRunning"> 
       <processModel idleTimeout="00:01:00" /> 
       <recycling> 
        <periodicRestart time="00:00:00"> 
         <schedule> 
          <clear /> 
          <add value="01:00:00" /> 
         </schedule> 
        </periodicRestart> 
       </recycling> 
      </add> 
    </applicationPools> 
</system.applicationHost> 
+0

你是什麼意思不工作?根本沒有超時或沒有期望的超時?您是否正在使用IIS,IIS-Express或Cassini測試您的Web應用程序,以及哪個版本?你在調試模式下測試嗎? ('web.config中的'

+0

@Frédéric,我的意思是根本沒有超時。換句話說,超時後,用戶不會重定向到登錄頁面。我正在使用Microsoft Windows Server 2012 R2上的IIS V8.5.9600.16384測試Web應用程序。謝謝 –

回答

0

的設置,看來你所期望的應用程序池idleTimeout造成的認證超時。這是無關的。此超時會觸發應用程序池回收,這會導致您的應用程序進程停止(如果請求來臨,則會進行更新)。

發佈的身份驗證票據不受此流程回收的影響(至少在Asp.Net Identity等框架中,只要您的站點計算機密鑰不更改)。

您應該尋求並設置您的身份驗證框架的超時。以Owin爲例,這可以在發行票時設置。

var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; 
// Your custom expiration, preferably taken from some settings 
var expiration = rememberMe ? 144000 : 30; 
var now = DateTimeOffset.UtcNow; 
authenticationManager.SignIn(
    new AuthenticationProperties 
    { 
     AllowRefresh = true, 
     IssuedUtc = now, 
     ExpiresUtc = now.AddMinutes(expiration), 
     IsPersistent = rememberMe 
    }, claimsIdentity);