我编码为我的基于mojoportal-iPhone优化的网站上的亚洲语言的学习模块(工作正在进行中,英文资源没有得到充分翻译:http://ilearn.dandandin.it/kanatrainer.aspx)为什么在某些浏览器中,我的Session对象的值不正确?
这是一个简单的“猜怎么看这个”游戏,与存储在Session对象中的正确答案。
我不明白为什么,但是,expecially使用Safari浏览器,用户将获得别人的会话值
这是从代码的摘录(我删除一些东西,翻译变量)
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
...
generateRandom();
}
}
protected void generateRandom()
{
int i, j = 0, livello = 5, chance = 0;
System.Random acaso = new Random();
...
while (j <= 0)
{
j = acaso.Next((Convert.ToInt32(TextBoxlunghezza.Text) + 1));
}
...
for (int k = 0; k < j; k++)
{
i = acaso.Next(livello);
Session["randomLetters"] += (globals.asianCharacters[i]);
...
}
...
}
protected void AnswerButton_Click(object sender, EventArgs e)
{
string compare = Server.HtmlEncode(InputTextBox.Text.ToLower());
if (compare == "")
{
Label1.Text = ("You did not write anything");
return;
}
if (Session["randomLetters"].ToString() != compare)
{
Label1.Text = ("Wrong!" + Session["randomLetters"]);
}
else
{
Label1.Text = ("Right!" + Session["randomLetters"]);
}
...
}
发生在视觉工作室,每个浏览器:
randomLetters是“你好”。用户在文本框中写入“hello”,并将“hello”与“hello”进行比较。标签上写着“正确!你好”。
在IIS中会发生什么事,只是在基于WebKit的浏览器:
randomLetters是 “你好”。用户在文本框中输入“hello”,但“hello”与“goodbye”比较。标签上写着“错误!再见”。
我不明白如何会话[ “randomLetters”]已经改变
公共VS私有代码:
我使用Session [“名称”] – 2011-05-09 09:49:50
嗯,我的意思是,怎么是会话[“名称”]为存储在服务器上? http://msdn.microsoft.com/en-us/library/ms178586.aspx – 2011-05-09 14:29:34
我认为它存储在服务器上,并通过保存在cookie上的标识符检索,或者如果cookie支持它被禁用,则在url中传递值 – 2011-05-09 15:01:43