在asp.net中维护会话 [英] maintaing session in asp.net

查看:86
本文介绍了在asp.net中维护会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是asp.net的初学者。我能够按如下方式维持会话:


索引页面中的
即第一页

i am beginner in the asp.net. i was able to maintain session as follows:

in index page i.e first page

protected void btnLogin_Click(object sender, EventArgs e)
       {
           Session["UserName"] = txtLogin.Text;
           Response.Redirect("~/mainPage.aspx");
       }





in second page





in second page

protected void Page_Load(object sender, EventArgs e)
       {
           if ( Session["UserName"] == null)
           {
               Response.Redirect("~/index.aspx");
           }
       }



但是我没有在web.config中做任何改动..这怎么可能有人请建议我链接进一步研究。我对这些事感到困惑。 :)

提前感谢.. :)


but i don't make any changes in web.config.. how is that possible and someone please suggest me links for further study. i am getting confused with these things. :)
thanks in advance.. :)

推荐答案

您好b $ b

以下链接可能对你有帮助。



在ASP.NET中探索会话 [ ^ ]







问候

Dominic
Hi
The below link may helpful to you.

Exploring Session in ASP.NET[^]



Regards
Dominic


您好,



请参阅此内容。



< a href =http://msdn.microsoft.com/en-us/library/75x4ha6s.ASPX> http://msdn.microsoft.com/en-us/library/75x4ha6s.ASPX [< a href =http://msdn.microsoft.com/en-us/library/75x4ha6s.ASPXtarget =_ blanktitle =New Window> ^ ]



初学者教程ASP.NET状态管理 [ ^ ]



http://www.tutorialspoint.com/asp.net/ asp.net_managing_state.htm [ ^ ]



希望这些文章能为您提供帮助。
Hi,

Refer this.

http://msdn.microsoft.com/en-us/library/75x4ha6s.ASPX[^]

A Beginner's Tutorial on ASP.NET State Management[^]

http://www.tutorialspoint.com/asp.net/asp.net_managing_state.htm[^]

Hope these articles will help you.


在ASP.NET中 Page_Load 事件在 btnLogin_Click 事件之前引发。

当用户点击按钮时,它会生成一个回发(该页面将被发回到Web服务器)并在那里以标准顺序管理事件。

这是 MSDN链接 [ ^ ]为您提供有关ASP.NET页面生命周期的概述。



这是起点链接 [ ^ ]。
In ASP.NET Page_Load event is raised before btnLogin_Click event.
When the user click on a button it generate a postback (the page is send back to the web server) and there the events are managed in a standard order.
Here is a MSDN link[^] that gives you an overview about ASP.NET Page Life Cycle.

And here is a starting point link[^] for creating and working with ASP.NET projects.


这篇关于在asp.net中维护会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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