如何限制一个用户在ASP.NET测验应用程序中进入另一个用户会话 [英] How to restrict one user enter into another user session in ASP.NET quiz application

查看:55
本文介绍了如何限制一个用户在ASP.NET测验应用程序中进入另一个用户会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net和c#中实现了测验应用程序。



我的应用程序中有一个用户登录并进行测试。



测试中间他将关闭浏览器而不退出。



然后另一位用户登录相同的应用程序,但用户名和密码不同但这个用户进入以前的用户会话。





我怎么能解决这个问题。使用会话或cookie解释示例



我尝试过:



如何限制一个用户在asp.net测验应用程序中进入另一个用户会话

解决方案

引用:

然后另一个用户登录了相同的应用程序,但用户名和密码不同,但是这个用户进入以前的用户会话。



怎么说?你的会话管理错了。



我们怎么猜猜你做错了什么?



As你说,一个具有不同用户名的新用户日志,最终会在之前用户的会话中结束。

Quote:

用户将在第4个模块关闭浏览器而不注销。

然后新用户登录相同的应用程序但不同的凭据但他进入第4个模块而不是第1个模块。

so他进入以前的用户会话。



是的,这就是问题,你没有在会话中存储用户ID,或者你没有检测到它不是同一个用户。 / blockquote>

问题是您没有正确分离用户:您需要使用数据库或cookie来分别存储每个用户的进度。 Cookies意味着它特定于该机器上的浏览器,这可能是错误的方法(并且意味着您需要遵守GDPR规定的规则,这可能是广泛的)。



您需要做的是使用Session对象将浏览器会话与特定用户相关联:通过DB将其登录并将UserID存储在Session中。然后,当他们取得进展时,您将其存储在数据库中,针对该特定用户。



当他们登录时,将从数据库中读取相同UserID的进度他们可以从他们所处的位置继续。



听起来好像你现在使用的是 static 变量或一个简单的文件来告诉你用户已经有多远,并且在多用户系统中永远不会有效。


i am implemented quiz application in asp.net and c#.

in my application one user logged in and doing test.

middle of the test he will close the browser without logged out.

then another user logged in same application but different username and password but this user enter into previous user session.


how i can solve this problem. using sessions or cookies explain with example

What I have tried:

how to restrict one user enter into another user session in asp.net quiz application

解决方案

Quote:

then another user logged in same application but different username and password but this user enter into previous user session.


How to say? Your session management is wrong.

How are we supposed to guess what you did wrong?

As you said, a new user log with a different username and end up in session of previous user.

Quote:

the user will close browser at 4th module with out logged out.
then new user logged in same application but different credentials but he enter into 4th module not 1st module.
so he enter into previous user session.


Yes, that is the problem, you do not store the user id with the session or you fail to detect that it is not the same user.


The problem is that you are not separating users properly: you need to either use a database or cookies to store each user's progress separately. Cookies would mean that it's specific to that browser on that machine, which is probably the wrong approach (and means that you need to follow the regulations laid down for GDPR, which can be extensive).

What you need to do is to use the Session object to associate a browser session with a specific user: log them in via a DB and store the UserID in the Session. Then when they make progress, you store that in the DB against that specific user.

When they log in, the progress is read back from the DB against the same UserID and they can continue from the point they were at.

It sounds like at the moment you use a static variable or a simple file to "tell you" how far a user has got, and that will never work in a multiuser system.


这篇关于如何限制一个用户在ASP.NET测验应用程序中进入另一个用户会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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