Im building a web application that charges for access on a per user basis. Ive used standard roles and membership for setting up accounts and logging in. I want to ensure that a client cant use the same user details to login more than once
ie if user abc1 is already logged in, someone else cannot login again using the same credentials
FormsAuthentication.RedirectFromLoginPage(txtUser.Text, false); After doing this, the user is logged in with the txtUser.text
But the question now is, how do i retrieve that user name from Authentication or whatever on other pages? is it possible or not?
Because i know that person stays logged in untill he logs out with this code: FormsAuthentication.SignOut();
And one more question i dont know is this one good for this or not how do i better check if the person is typed in correct name and pasword or not, with executescalar or executereader?
I have a login form from the membership and I am trying to make it so that it would redirect depending on role. I have tried to put this code under login1_loggedin but it didn't seem to work. how can I do this?
I am currently using the built in ASP login function... the destinationpageurl of that login function locates to "loginhome.aspx" for all users... but for one specific user ("Admin") it needs to link to "adminhome.aspx"... just wondering whats the best way to do this? Can I change the destinationpageurl of the login function depending on the user or creating an admin role so "If membershiprole = 'Admin' redirect to 'adminhome.aspx' End If" or can I just add some code behind the login function so "If User.login.Name = 'Admin' Then destinationpageurl = 'adminhome.aspx' End If" think I have already tried this on the login1_authenticate event but it didn't work
User 1 logs in the domain. User 1 changes some data without saving it. User 2 logs in the domain in a separate tab. User 1 switches back to his tab and saves the data. User 1 actually saved the data into User 2!!
This is caused by the following mechanism:
Different tabs in the same browser seems to share the same session id. We are storing user auth in cookie and the cookie is shared between tabs (same domain)
Therefore, when User 1 request to save, it is recognized as User 2 since the cookie has been updated to User 2.
So I'm wondering if there's any other methods to prevent this from happening, other than:
1. Use cookieless session so the session is embedded in uri.
2. Always include a hidden field in page to indicate which user owns the page.
I have this web application built. I am using windows authentication for this application. I have to log all the user activity as wells as site activity in this application. I have the below mentioned class established to log some activity regarding the user to an SQL server database table..
[code]....
I would still need to log many other items regarding the user and also the site, like the time spent by the user on the site, no: of currently logged in users on the site. Can anyone here suggest me as to how do I capture those items?? let me know if I am going in the right direction too.....?? If you can provide me with some links on this "user activity logging for windows authenticated applications".
I think my subject line explains my problem in a nutshell.. I have a login page, I login like I should and everything works.I logout and when I type/paste the address to the page, in the address field, I still reach it just like if I was still logged in..The page I type in the address field is in a subfolder, only suppose to be able to be reached by logged in users and in this folder,ith it's own web.config-file:
When clicked on particular URL, i need to pass whether user has checked REMEMBER ME CHECKBOX while logging in. How can I determine this using FOrmsAuthentication mechanism?
I'm debugging some unexpected behavior and while tracing in to the .NET framework I see a bunch of stuff like this:
if (Logging.On) { Logging.PrintInfo(Logging.Web, this, SR.GetString(SR.net_log_n_certs_after_filtering, filteredCerts.Count)); ... }
But (as expected by default) the execution steps right over these. Is there some way to turn on the logging? Or is that just something that the framework developers can do while making special builds of the framework?
I was adding login and logout functionality to my ASP.NET website. While I am able to make the user log in by checking the username and password but on some pages should be available only if he is logged in. I am doing this by storing the user's value in a session
Secondly, I am using a Link button which changes to Logged in as example. So, how does the user log out?
I have created a login page which uses the Login control. If the user is not already registered they a redirected to another page to register. My client wants them to be logged in from when they register, and taken to the main page of the application.
How do I log a user in manually, without using the Login control? Am using forms authentication, and have the dbo.aspnet table and stored procedures already created.
I'm very new to asp.net and c#, I understand the basics but don't understand how to create a login system using C# to connect and login using a Microsoft Access Database.
I Am using the basic ASP.Net controls. This worked yesterday and I don't believe I changed anything but when I came back today I could not login due to an error "Invalid postback or callback argument" which really confused me because like i said, it worked yesterday. I researched and found a solution to fix that was to set
[Code]....
I did that and now can login again however can no longer logout. The controls are all on the masterpage as posted below
The db connection seems to work. I can create new users with the new user wizard control. And they show up in the databaser. But i cant log in. I use the log in control and just get "wrong password". I am sure i type the correct password as i made it very easy. here are my webconfig settings.
There is one thing i have no clue how to configure. The APPLICATION NAME. What is it? And what should i set it to?
Is there something here messing up my login functionality? I can't log in. Before when I was logged in, I couldn't log out. It seems to have started when I clicked on "Remember me". Could there be something conflicting with web.config and the aspnetdb profile provider service setting that was initially set regarding profiles/roles/access?
I have a requirement to log all/most forms authentication transactions that take place within my page. For example, if someone is kicked out because of forms authentication, I'd like to get their username, time when kicked off, and where this happened. Is there a good way to do this. Better yet, has anyone done this already and is willing to share some code or post a link?
How can I prevent user to go back after logging out from any of the page of my website ? Even if the user press back button, redirected to the login.aspx page. Like we have seen in social or any other member ship sites.
I am involved in designing a asp.net webforms application using .NET 3.5. I have a requirement where we need to log exceptions.
What is the best approach for exception handling, given that there would be concurrent users for this application?
Is there a need or possibility to log in exceptions at a user level? My support team in-charge wants to have a feature where the support team can get user specific log files.
To give you a background, this application is currently on VB 6.0 and we are migrating it along with some enhancements. So, today the support personnel have a provision to get user specific log files.
I am trying to insert a string and random number into the database as hash sha1 then loggin in against it. the problem is if I use hash it wont login but if i dont use hash the login works fine... Code below.
insert hash into db Dim user As New Label user.Visible = False user.Text = (myDataReader2.Item("username")) MyConnection2.Close() Dim MyConnection3 As New Data.SqlClient.SqlConnection("Data Source=xxx") Dim mycommand3 As New Data.SqlClient.SqlCommand("Update Register SET [Password] = @password WHERE [username] = '" & user.Text & "' AND [email] = '" & email.Text & "'", MyConnection3) Dim pass As String Dim rnd As Integer, randomNum As New Random rnd = randomNum.Next(1000, 10000) pass = "Pass" & rnd mycommand3.Parameters.AddWithValue("@password", FormsAuthentication.HashPasswordForStoringInConfigFile(pass, "SHA1")) MyConnection3.Open() mycommand3.ExecuteNonQuery() login page Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) ' Fires upon attempting to authenticate the use If Not (HttpContext.Current.User Is Nothing) Then If HttpContext.Current.User.Identity.IsAuthenticated Then If TypeOf HttpContext.Current.User.Identity Is FormsIdentity Then Dim fi As FormsIdentity = CType(HttpContext.Current.User.Identity, FormsIdentity) Dim fat As FormsAuthenticationTicket = fi.Ticket Dim astrRoles As String() = fat.UserData.Split("|"c) HttpContext.Current.User = New GenericPrincipal(fi, astrRoles) End If End If End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim myConnection As New SqlClient.SqlConnection Dim myCommand As New SqlClient.SqlCommand Dim intUserCount As Integer Dim strSQL As String myConnection = New SqlClient.SqlConnection("Data Source=jrome2.db.4961680.hostedresource.com; Initial Catalog=jrome2; User ID=jrome2; Password=Richard050283;") strSQL = "SELECT COUNT(*) FROM Register " _ & "WHERE UserName='" & Replace(txtusername.Text, "'", "''") & "' " _ & "AND Password='" & Replace(txtpassword.Text, "'", "''") & "';" myCommand = New SqlClient.SqlCommand(strSQL, myConnection) myConnection.Open() intUserCount = myCommand.ExecuteScalar() myConnection.Close() 'Response.Write(intUserCount) If intUserCount > 0 Then FormsAuthentication.Initialize() Dim strRole As String = AssignRoles(txtusername.Text) 'The AddMinutes determines how long the user will be logged in after leaving 'the site if he doesn't log off. Dim fat As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, _ txtusername.Text, DateTime.Now, _ DateTime.Now.AddMinutes(30), False, strRole, _ FormsAuthentication.FormsCookiePath) Response.Cookies.Add(New HttpCookie(FormsAuthentication.FormsCookieName, _ FormsAuthentication.Encrypt(fat))) Response.Redirect(FormsAuthentication.GetRedirectUrl(txtusername.Text, False)) Else login.Text = "Incorrect Log In Information" End If End Sub Private Function ValidateUser(ByVal strUsername As String, ByVal strPassword As String) _ As Boolean 'Return true if the username and password is valid, false if it isn't Return CBool(strUsername = " & Replace(txtusername.Text, " AndAlso strPassword = " & Replace(txtpassword.Text, ") End Function Private Function AssignRoles(ByVal strUsername As String) As String Dim myConnection As New SqlClient.SqlConnection Dim myCommand As New SqlClient.SqlCommand Dim intUserCount As Integer Dim strSQL As String myConnection = New SqlClient.SqlConnection("Data Source=jrome2.db.4961680.hostedresource.com; Initial Catalog=jrome2; User ID=jrome2; Password=Richard050283;") strSQL = "SELECT COUNT(*) FROM Register " _ & "WHERE UserName='" & Replace(txtusername.Text, "'", "''") & "' " _ & "AND Password='" & Replace(txtpassword.Text, "'", "''") & "';" myCommand = New SqlClient.SqlCommand(strSQL, myConnection) myConnection.Open() intUserCount = myCommand.ExecuteScalar() myConnection.Close() 'Response.Write(intUserCount) If intUserCount > 0 Then Return "client" Else Return String.Empty End If End Function Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) txtusername.Text = String.Empty txtpassword.Text = String.Empty End Sub
I have a website built in ASP.net 3.5, using WinForms and AjaxToolKit. I have encountered a lost/corrupt session issue while using Internet Explorer 8.
1. Login, Redirect to Landing, Logout - WORKS AS EXPECTED 2. Login, redirect to Landing, Close Window, Open Window, Logged-in already - WORKS AS EXPECTED (remember me enabled by default in code)
1 IE8 Browser, 2 Tabs -------------------------------------- 1. Login, Redirect to Landing, Open new tab, paste Landing page URL, Landing renders. - WORKS AS EXPECTED - Logout from Tab 2, Tab 1 logs out after AJAX update. - WORKS AS EXPECTED - Login from Tab 1, Redirects to Landing, then Redirects back to Login page - ISSUE
[code]...
2. Close Window,Login,Redirect to Landing - WORKS AS EXPECTED
2 IE8 Browser, 1 Tab -------------------------------------- 1. Open 2 IE windows 2. In Window 1, Login, Redirect to Landing, then Redirects back to Login. - ISSUE - Window 2 Paste Landing page URL, Landing page renders - ISSUE, STRANGLY NOW WORKS
[code]...
This issue seems to only happen when I have multiple tabs open,or multiple rwssers open.Firefox and Chrome does not reproduce this issue and works as expected.How do I make sure the Cookie/Session is being handle correctly in IE8?
Here is my Login Auth:
[Code]...
Web.Config
[Code]...
Server 2008r2 Seesion State: Cooke Settings: Mode: Use Cookies;
I have a problem configuring web.config file. In root directory I have a web site that doesn't require logging in to be viewed (public section of the web site) and I also have a folder ("Administration") that needs logging in to get access to it. Login.aspx is located in folder "Administration".
The question is how to properly set up the web.config to connect Administration/Login.aspx with Administration/Default.aspx. I tried editing web.config in root directory by adding the following lines, but it only shows me Login.aspx and it redirects me to the public section:
[Code]....
Do I also have to add web.config in "Administration" folder and with which parameters?
So its a ASP.NET problem where two users using the same machine, same browser:
User 1 logs in the domain. User 1 changes some data without saving it. User 2 logs in the domain in a separate tab. User 1 switches back to his tab and saves the data. User 1 actually saved the data into User 2!!
This is caused by the following mechanism:
Different tabs in the same browser seems to share the same session id.
We are storing user auth in cookie and the cookie is shared between tabs (same domain)
Therefore, when User 1 request to save, it is recognized as User 2 since the cookie has been updated to User 2.
So I'm wondering if there's any other methods to prevent this from happening, other than:
1. Use cookieless session so the session is embedded in uri. 2. Always include a hidden field in page to indicate which user owns the page.