c# - 使 session 过期

标签 c# asp.net

我在 web.config 文件中使用 authentication mode=forms。因为它是一个安全的应用程序,所以我想在 5 分钟后结束我的 session 。现在我正在代码隐藏中进行编程。

还有其他简单的方法吗?

最佳答案

您应该在 Web.config 文件中执行此操作。这将使 Session

过期
<configuration>
  <system.web>
    <sessionState 
      mode="InProc"
      cookieless="true"
      timeout="5" />
  </system.web>
</configuration>

另一种选择是,这将使 cookie 过期

<authentication mode="Forms">
   <forms name=".ASPXAUTH" loginUrl="Login.aspx" protection="All" timeout="5" path="/" slidingExpiration="true">
   </forms>
</authentication>

关于c# - 使 session 过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6084230/

相关文章:

c# - 向 WinForm 缓慢添加许多标签

c# - UserManager<User> 在数据库中找不到现有用户 asp.net core Identity

c# - 无法在生成的 PDF 中正确显示泰米尔语

asp.net - WebMatrix Razor 页面和全局 using 语句

c# - 处理所有已注册的服务?

c# - 在 GET/POST 上为 ViewModel 填充 SelectList 的最佳方法

c# - 为什么我无法调用 WriteLogDataToDb 方法?

c# - 使用 C# 仅获取 JSON 的一部分

asp.net - 将 SQL Server 上的 Asp.net WebApp 移动到 MySQL 有哪些潜在问题?

c# - 如何在 C# ASP.NET MVC 5 中找到我们来自的 View (内置方式)?