变量在其他计算机ASP.Net VB.Net上保留了它的价值 [英] Variable retained its value on other computers ASP.Net VB.Net

查看:84
本文介绍了变量在其他计算机ASP.Net VB.Net上保留了它的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使其他计算机访问我的网站,我的变量也会保留其价值。例如,我使用Username - User1登录了PC 1。当我在PC 2上访问该网站时,User1已经登录。希望有人可以帮我这个。



i有一个变量



public用户名为字符串



则代码为

My variables is retaining its value even if other computers accessing my website. for example, i logged in the pc 1 using Username - User1. when i access the site on pc 2, the User1 is already logged in. Hope some one could help me on this.

i have a variable

public Username as string

then the code is

Username = txtUsername.text 



我将使用用户名test_user1登录到PC 1



when我访问另一台PC或计算机上的网站,用户名test_user1仍在变量Username上。



问题是为什么它在其他计算机上继承或保留变量Username的值?



i使用下面的代码


Im going to log in to PC 1 using username "test_user1"

when i access the website on another pc or computer, the username "test_user1" is still on the variable Username.

The question is why it inherit or retain the value of the variable "Username" on other computers?

i used this codes below

Protected Sub btnLogin2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnLogin2.Click

Username = txtUsername.text
FormsAuthentication.RedirectFromLoginPage(Username, False)
Response.Redirect("~/frmMenu.aspx", False)

End Sub





它不是关于身份验证,它关于我在模块上声明的变量以及为什么它与访问我网站的其他计算机具有相同的值。



Its not about the authentication, its about the variable i declared on the module and why it has same value accross other computers accessing my website.

推荐答案

您可能在项目中使用过静态变量。因此可能导致问题,请再次检查。
Might be you have used Static variable in your project. due to this the problem may caused , check it again.


检查是否已将变量声明为公共静态,这可能就是这种情况的原因。
And如果要将此名称访问另一个表单,请使用查询字符串,或者如果要通过会话将其访问,请将其存储在会话中。
check if you has declared variable as public static this could be a reason of such case.
And if you want to access this name to another form then use query string or if you want to access it through-out the session store it in session.


这篇关于变量在其他计算机ASP.Net VB.Net上保留了它的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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