如何"在session_start"在Global.asax中的作品? MVC [英] How "Session_Start" in Global.Asax works ?. MVC

查看:86
本文介绍了如何"在session_start"在Global.asax中的作品? MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我'尝试uderstand在session_start在Global.asax中是如何工作的。比方说,我有我的网站上几页。例如:我'进入的网页A,那么功能在session_start的发射。然后我'要页面B,什么不是?功能将再次点火,还是没有?我'尝试写code将检查cookie的用户的存在,如果存在,code将返回会话[username的]变量,但我'不知道是在session_start好去处该..

I'am trying uderstand how "Session_Start" in Global.Asax works. Let's say I've got few pages on my website. For example: I'am entering on "Page A", then function "Session_Start" is firing. Then I'am going to "Page B", and what than ?. Function will firing again, or not ?. I'am trying to write code which will check that cookie "User" exist, and if exist, code will return Session["userName"] variable, but I'am not sure is "Session_Start" good place for that..

推荐答案

如果你想无限的会话,你可以使用cookie。
我认为你正在使用,你提到,在您的原始查询。

If you want to make session unlimited, you can use cookies. Which I think you are using, you mentioned that in your original query.

当用户注销Session_End中被激发,关闭浏览器结束会话或会话超时。

Session_End is fired when user logs out, closes browser to end the session or session times out.

您可以保留用户的浏览器cookie的。并检查在session_start cookie的有效值。并恢复用户的会话。

You can keep the cookie on user's browser. And check the cookie in Session_Start for valid values. And resume the session for the user.

您也可以从服务器配置增加会话超时。

You can also increase the session timeout from server configuration.

这篇关于如何"在session_start"在Global.asax中的作品? MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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