VB.NET会话变量 [英] VB.NET Session Variables

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

问题描述





我使用asp.net& amp;创建了一个包含5个表单的Web应用程序。 vb.net。



该系统拥有超过250个网络客户端。



我的问题是当第二个用户登录到Web系统时,第二个用户会覆盖第一个用户的详细信息。



我想从登录页面获取User_ID,用户名,用户ID和所选分支名称,并希望在其他5个页面的文本框中显示这些信息。

所以在其他页面中,我想使用用户ID从mySQL表中提取信息。



这是我的代码。

Login.aspx.vb(First Form)

Hi,

I have created a web application with 5 forms using asp.net & vb.net.

The system got more than 250 web clients.

My problem is when the second user logs in to the web system, the second user overrides first user's details.

I want to get the User_ID, username, user ID and the selected branch name from the Login page and want to display those information on text boxes in other 5 pages.
So in other pages I want to use user id to extract information from mySQL tables.

This is my code.
Login.aspx.vb (First Form)

Protected Sub bttnLogin_Click(sender As Object, e As ImageClickEventArgs) Handles bttnLogin.Click
     
        Session("UserName") = Server.HtmlEncode(txtUserName.Text)
        Response.Redirect("~/default.aspx";, True)


    End Sub





第二张表格



2nd form

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
       lblDetails.Text = Session("UserName")
   End Sub



但是当两个或多个用户登录到系统时,它会在lblDetails.Text上显示正确的用户名,但当你刷新页面时它会显示最后登录用户的详细信息。



< br $>






请帮帮我。







谢谢


But at the moment when two or more users logs to the system it's showing the correct usernames on "lblDetails.Text" but when u refresh the page it will show last logged in user's details.





Please help me.



Thanks

推荐答案

将查询字符串参数传递到下一页几乎更简单用户详细信息。如果用户要刷新页面,您可以检索字符串参数以再次显示用户信息,并使用参数从数据库中检索任何信息。



I如果你只参加会议,你也会通过使用多个会话来同意sergey。
it would almost be simpler to pass query string parameters to the next page with the users details. if the user were to refresh the page you are able to retrieve the string parameters to display the user info again and retrieve any info from your database using the parameter.

I would also agree with sergey by using multiple sessions if you went the rout of sessions only.


这篇关于VB.NET会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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