TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sourav Bhattacharya
NA
78
12.2k
How to prevent concurrent login of user from multiple browser
Mar 13 2021 11:29 AM
Hi there,
I have been developing an ASP.NET Web application in .NET Framework 4.7.2.I need to incorporate prevention of concurrent login of same user from multiple browsers or from multple devices.I considered to use Session in SQL Server mode for the said purpose.Currently I am facing the following error :-"failed to login to session state sql server for user" after installing aspnet_regsql.exe ,InstallCommon.Sql,InstallSqlState.Sql and InstallSqlTemplate.Sql.The code web.config file is:-
<sessionState mode=
"SQLServer"
cookieless=
"true"
regenerateExpiredSessionId=
"true"
allowCustomSqlDatabase=
"true"
stateConnectionString=
"Data Source=DESKTOP-NT0TKOE\SQLEXPRESS;Initial Catalog=aspnetdb;Persistent Security=true;Integrated Security=SSPI;"
timeout=
"60"
>
</sessionState>
I have also set a field of bit data type which is set to zero by default such that when a user logges in it is updated to one and there concurrent login is denied due to the following code in Login.aspx.cs file:-
TestEntities dbo =
new
TestEntities();
var flag = dbo.Logins.Where(u => u.Username ==
this
.cntLogin.UserName && u.Password ==
this
.cntLogin.Password).FirstOrDefault();
if
(flag !=
null
)
{
var temp = dbo.Tokens.Where(u => u.Username ==
this
.cntLogin.UserName && u.Tokenvalue ==
false
).FirstOrDefault();
if
(temp !=
null
)
{
HttpContext.Current.Session[
"Username"
] =
this
.cntLogin.UserName;
HttpContext.Current.Session[
"Password"
] =
this
.cntLogin.Password;
FormsAuthentication.RedirectFromLoginPage(
this
.cntLogin.UserName,
this
.cntLogin.RememberMeSet);
}
}
else
{
this
.cntLogin.FailureText =
"Username and/or password is incorrect."
; where cntLogin
is
the Id of asp:Login control.
}
Can you help me out??
Reply
Answers (
4
)
Can anyone please give me visual studio 2017 professional?
Is asp.net web form dead? and only asp.net mvc is there?