gpt4 book ai didi

c# - 在 C# 中测试 session 超时

转载 作者:太空狗 更新时间:2023-10-30 01:15:11 25 4
gpt4 key购买 nike

我在 web.config 中将我的 session 超时设置为 1。我想检查 session 开始和结束是否按预期发生,所以我在 global.asax.cs 中有这个-

//In Session_Start
Response.Write("<script>alert('session started');</script>");
//In Session_End
Response.Write("<script>alert('session ended');</script>");

我在 session 开始时收到警报,但在结束时没有。当我放置断点时,我看到该行在 Session_End 中执行,但屏幕上没有警告。

这是我第一次使用 session ,尽管我能够以其他方式测试功能,但我很好奇为什么它没有显示警报。

提前致谢。

最佳答案

我知道您希望写入响应而不是重定向,但看看这个:Redirecting to another page on Session_end event另一页 session 结束事件

Session_End is called when the session ends - normally 20 minutes after the last request (for example if browser is inactive or closed). Since there is no request there is also no response.

这强烈建议您不能写入响应...因为没有响应。

关于c# - 在 C# 中测试 session 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39472826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com