身份验证超时无法正常工作 [英] Timeout in authentication does not work properly

查看:40
本文介绍了身份验证超时无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ASP.NET 4 站点.我在 web.Config 中的身份验证中将超时设置为 100 分钟,但是当用户突然使用站点时,站点会在 3 分钟后提示登录.下面的代码是我的 web.Config 文件

I have an ASP.NET 4 site. I'v set timeout to 100 minutes in authentication in web.Config, but when users are working with site suddenly the site prompts to log in even after 3 minutes. The below code is my web.Config file

    <?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>

推荐答案

确保您没有在代码中创建 FormsAuthenticationTicket.这将覆盖您在 web.config 中配置的超时值.如果你在你的代码中做这样的事情,这可能是它不工作的原因:

Make sure you are not creating a FormsAuthenticationTicket within your code. This would override the timeout value you have configured in your web.config. if you are doing something like this in your code, it could be the reason of why it is not working:

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

如果您没有执行上述操作,请查看您的 SessionTimeout.也尝试增加它.

In case you are not doing the above, take a look at your SessionTimeout. Try increasing it as well.

问候.

这篇关于身份验证超时无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆