2012-10-30 133 views
3

我有一個ASP.NET 4站點。我在web.Config中將身份驗證超時設置爲100分鐘,但是當用戶正在使用站點時,即使3分鐘後站點也會提示登錄。以下代碼是我的網頁.Config文件身份驗證超時無法正常工作

<?xml version="1.0" encoding="utf-8"?> 
    <!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 
    <configuration> 
    <appSettings> 
    <add key="ImageMaxFileLengh" value="500" /> 
    </appSettings> 
    <system.web> 
    <pages enableViewStateMac="false"></pages> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
     <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> 
     <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
     <add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     </assemblies> 
    </compilation> 
    <authentication mode="Forms"> 
     <forms defaultUrl="~/Default.aspx" loginUrl="~/Account/Login.aspx" timeout="100" name="HajLogin" slidingExpiration="true" /> 
    </authentication> 
    <!--<membership> 
     <providers> 
     <clear /> 
     <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> 
     </providers> 
    </membership> 
    <profile> 
     <providers> 
     <clear /> 
     <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" /> 
     </providers> 
    </profile> 
    <roleManager enabled="false"> 
     <providers> 
     <clear /> 
     <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> 
     <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> 
     </providers> 
    </roleManager>--> 
    <httpHandlers> 
     <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" /> 
    </httpHandlers> 
    </system.web> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
     <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" /> 
    </handlers> 
    </system.webServer> 
</configuration> 

回答

4

請不要混淆超時進行身份驗證,會話超時。

尋求身份驗證時,表單1000會超時。驗證完成後,您不會查看此變量,以便驗證的會話過期。

這裏是描述差別一些很好的鏈接:

這裏是一個很好的鏈接描述設置在窗體身份驗證會話超時:

+0

鏈接1和2不是我的問題。我使用鏈接3,但它不能解決我的問題,用戶提示10分鐘前登錄 –

3

確保您未在​​代碼中創建FormsAuthenticationTicket。這將覆蓋您在web.config中配置的超時值。如果你正在做這樣的事情在你的代碼,這可能是爲什麼它不工作的原因:

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket 
(
    ... 
    DateTime.Now, // issueDate 
    DateTime.Now.AddMinutes(30), // expiration 
    ... 
); 

如果你不這樣做上述情況,看看你的SessionTimeout。嘗試增加它。

問候。

+0

thanx很多,但我沒有任何FormsAuthenticationTicket,我添加會話超時到web.Config,我會測試 –

相關問題