调用global.asax中的session-Start事件时 [英] When session-Start event in the global.asax is called

查看:121
本文介绍了调用global.asax中的session-Start事件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊重所有



今天我感到困惑的是,global.asax中的会话启动功能何时被称为。



我们知道在创建新用户的会话时会调用它。



我的问题是



当需要在应用程序中创建会话以进行状态管理时会发生什么?它是否被调用

如何在用户打开网站时访问由asp.net创建的会话。



问候

TanzeelurRehman

解决方案
#在session_start:当一个新的用户访问应用网站燃

#Session_End中:当用户的会话超时,结束或者提交应用程序网站时触发。



或者查看链接, -



http://www.techrepublic.com/ article / with-the-aspnet-globalasax-file / 5771721 [ ^ ]



希望这可以帮到你。


< blockquote>浏览本文,确保阅读文章中的生命周期事件和Global.asax文件部分: MSDN:IIS 5.0和6.0的ASP.NET应用程序生命周期概述 [ ^ ]


否默认情况下,您的ASP.NET Web应用程序将为用户创建数据存储会话。



当用户第一次访问时,会话开始网页。如果他在特定持续时间内没有做任何事情,则服务器处理为用户分配的会话内存。会话过期时间在服务器上配置。现在,当用户在会话过期后再次点击某个页面时,会再次创建一个新会话并分配给用户请求。



如何访问用户在打开网站时为用户创建的会话



我相信一个谁正在访问会话这里是一个Web开发人员,你不必做任何特别的事情,.net框架为所有与会话相关的操作提供Session类。



网站用户无法访问Session变量,因为它是服务器端功能。想象一下,如果该功能向网络用户公开,他可能会对您的网站造成错误。



此外,如果您想添加任何内容,您只需使用Session [yourkeyName ] =密钥的值它会自动创建yourkeyName密钥(如果它不存在)并为其添加值并获得存储的值,只需编写someVariable = Session {yourKeyname]。



希望答案能澄清疑惑。



谢谢,

Hemant







有两种方法可以让所有活动的会话变得简单或困难:

1-简单方法(即使用应用程序级变量来存储信息)

http://stackoverflow.com/questions/1470334/list-all-active-asp-net-sessions [ ^ ]

http://stackoverflow.com/questions/1347007/how-can-i-view-everything-in-session-state-for-all-active-sessions [ ^ ]



2-艰难的方式(即使用反思)

http:/ /weblogs.asp.net/imranbaloch/archive/2010/04/05/reading-all-users-session.aspx [ ^ ]



希望它会有所帮助。

谢谢,

Hemant


Respected All

Today i came with a confusion that when is session-start function in the global.asax called.

As we know that it is called when the session for new user is created.

My question is that

When there is needed to create session within the application for state management then what happens? it is called or not
How can one access the session created by asp.net for the user when he open the site.

Regards
TanzeelurRehman

解决方案

# Session_Start: Fired when a new user visits the application Website.
# Session_End: Fired when a user's session times out, ends, or theyleave the application Web site.

Or have a look on the link,-

http://www.techrepublic.com/article/working-with-the-aspnet-globalasax-file/5771721[^]

Hope this can help you.


Have a walk through this article, make sure you read "Life Cycle Events and the Global.asax file" section in the article: MSDN: ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0[^]


No matter session is required or not by default your ASP.NET web application will create session for data storage for a user.

A session starts when a user first time hits a web page. if he doesn't do any thing for specific duration the server disposes the session memory allocated for the user. The session expire duration is configured at server. Now when user again hits some page after his session expired the a new session is created again and assigned for user requests.

How can one access the session created by asp.net for the user when he open the site

I belive the one who is accessing session here is a web developer, well you dont have to do anything special, the .net framework provides Session class for all session related operations.

A web-site user cannot access the Session variables because it is a server side functionality. Imagine if the feature is exposed to web-user he can do blunders to your website.

Additionally if you want to add anything you can simply use Session["yourkeyName"] = "value for the key" it automatically creates the "yourkeyName" key if it doesn't exists and adds value to it and to get the value stored you simply write someVariable = Session{"yourKeyname"].

Hope the answer will clarify the doubts.

Thanks,
Hemant

Hi,

Well there are 2 ways of getting all active sessions it an easy way or a hard way:
1- easy way (i.e. use application level variable to store information)
http://stackoverflow.com/questions/1470334/list-all-active-asp-net-sessions[^]
http://stackoverflow.com/questions/1347007/how-can-i-view-everything-in-session-state-for-all-active-sessions[^]

2- hard way (i.e. use reflection)
http://weblogs.asp.net/imranbaloch/archive/2010/04/05/reading-all-users-session.aspx[^]

Hope it will help.
thanks,
Hemant


这篇关于调用global.asax中的session-Start事件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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