2012-10-30 66 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,我会测试 –

相关问题