2014-01-14 35 views
0

我已阅读少量帖子,但我不确定是否缺少某些内容,但我的Cookie超时时间很短。饼干超时一分钟后超时,即使我已将它设置为60分钟

这是我在我的web.config已设置:

<?xml version="1.0"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=152368 
    --> 
<configuration> 

    <appSettings> 
    <add key="webpages:Version" value="1.0.0.0"/> 
    <add key="ClientValidationEnabled" value="true"/> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 
    <add key="suburbanServiceUrl" value=""/> 

    </appSettings> 

    <system.web> 

    <sessionState 
     mode="InProc" 
     cookieless="false" 
     timeout="60" 
    /> 

    <customErrors mode="Off"/> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
     <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </assemblies> 
    </compilation> 
    <authentication mode="Forms"> 
     <!-- timeout: Gets and sets the amount of time, in minutes, allowed between requests 
        before the session-state provider terminates the session. --> 
     <forms loginUrl="~/Account/LogOn" timeout="60"/> 
    </authentication> 

    <membership> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlMembershipProvider" 
      type="System.Web.Security.SqlMembershipProvider" 
      connectionStringName="ApplicationServices" 
      enablePasswordRetrieval="false" 
      enablePasswordReset="true" 
      requiresQuestionAndAnswer="false" 
      requiresUniqueEmail="false" 
      maxInvalidPasswordAttempts="30" 
      minRequiredPasswordLength="6" 
      minRequiredNonalphanumericCharacters="0" 
      passwordAttemptWindow="10" 
      applicationName="webportal"/> 
     </providers> 

    </membership> 

    <profile> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="webportal"/> 
     </providers> 
    </profile> 

    <roleManager enabled="true"> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="webportal"/> 
     <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="webportal"/> 
     </providers> 
    </roleManager> 

    <pages enableSessionState="true"> 
     <namespaces> 
     <add namespace="System.Web.Helpers"/> 
     <add namespace="System.Web.Mvc"/> 
     <add namespace="System.Web.Mvc.Ajax"/> 
     <add namespace="System.Web.Mvc.Html"/> 
     <add namespace="System.Web.Routing"/> 
     <add namespace="System.Web.WebPages"/> 
     </namespaces> 
    </pages> 
    </system.web> 

    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false"/> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <remove name="Session"/> 
     <add name="Session" type="System.Web.SessionState.SessionStateModule"/> 
    </modules> 
    <httpProtocol> 
    </httpProtocol> 
    <staticContent> 
     <clientCache cacheControlCustom="public" 
     cacheControlMaxAge="00:00:01" cacheControlMode="UseMaxAge" /> 
    </staticContent> 
    </system.webServer> 

    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 

</configuration> 

我拿出连接字符串和servicemodel。

在IIS中我有这一套:

enter image description here

我相信我拥有了一切设置为60分钟,但它绝对不是持续那么久。

任何人都可以看到我缺少的东西吗?

编辑

对不起,我包括在我处理超时问题在这里走出习惯的会话信息。无论如何,正如我告诉西蒙哈尔西下面:

我指的是会员cookie。我在一分钟左右后回到登录页面。我有[正在授权]我正在调用的方法,在我几分钟内无效后将其发送回登录屏幕

+0

您可能想从您的配置文件中删除该密码。你永远不知道某人可能会用它做什么。 –

+0

ty以为我得到了一切。幸运的是,它只是办公室的一个开箱。 – ErocM

回答

0

哪个cookie即将过期?根据我的看法,您拥有2个会员Cookie,会员Cookie为&。

您的会话cookie是浏览器会话cookie,因此没有设置到期时间 - 只有在浏览器处于打开状态时才存在。当你关闭浏览器时,会话cookie不见了。您的会话超时指的是会话状态在服务器上的持续时间。当你关闭浏览器时,会话一直持续到它超时。由于您关闭了浏览器,相应的会话Cookie被销毁,因此您无法恢复该会话。您可以劫持cookie &从另一个浏览器&呈现它会延长会话。

如果你改变了某些东西,例如配置文件,你会导致应用程序重新启动&这将会终止所有活动的会话。

成员cookie以类似的方式工作。它们也是浏览器会话cookie,除非您在用户登录时持久保存cookie。会员cookie包含一个表单验证票据,该票据也具有到期时间。如果每次访问该网站时都应该延长这个时间,只要该时间限制在机票的时间限制内。

+0

我指的是会员cookie。我在一分钟左右后回到登录页面。对于我正在调用的方法,我有'[Authorize]',这些方法在我处于非活动状态几分钟后将我发送回登录屏幕。 – ErocM

+0

您是否使用网络工具(例如小提琴手或网络浏览器工具)来检查请求并查看传递的内容? –

+0

'[Authorize]'与角色检查有关,而不是表单验证。如果启用了表单身份验证,它确实需要您登录,但通常用于检查用户是否处于角色中。我想知道这是为什么你会被重定向。 –