473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

ASP.NET {VB}: Login problem after hitting back button

viswammamilla
Hai i did one application ,its an intranet web application using asp.net and vb.net.
Once user login into the application and did some task whenever user hits back button it will come back to one page like that so on upto login window,then when user hits the forward button directly user getting into that application without entering certain details,so please help me please its urgent very very
Dec 2 '08 #1
2 1734
OuTCasT
374 256MB
You need to create a validation function to validate the username and password before letting the user continue.....You also add to the function that if the username does not match the password it wont let the user go forward, and visa versa.

Expand|Select|Wrap|Line Numbers
  1. Private Function ValidateUser(ByVal userName As String, ByVal passWord As String) As Boolean
  2.         Dim conn As SqlConnection
  3.         Dim cmd As SqlCommand
  4.         Dim lookupPassword As String
  5.  
  6.         lookupPassword = Nothing
  7.  
  8.         ' Check for an invalid userName.
  9.         ' userName  must not be set to nothing and must be between one and 15 characters.
  10.         If ((passWord Is Nothing)) Then
  11.             'Label1.Text = "[ValidateUser] Input validation of userName failed."
  12.             Return False
  13.  
  14.         End If
  15.         Try
  16.             ' Consult with your SQL Server administrator for an appropriate connection
  17.             ' string to use to connect to your local SQL Server.
  18.  
  19.             conn = New SqlConnection("Server=(local);Data Source=.\SQLEXPRESS;Initial Catalog='" & strCompanyName & "';Integrated Security=True;Pooling=False")
  20.             conn.Open()
  21.  
  22.             ' Create SqlCommand to select pwd field from the users table given a supplied userName.
  23.             cmd = New SqlCommand("SELECT [password] FROM [users] where [username]=@username", conn)
  24.             cmd.Parameters.Add("@username", SqlDbType.VarChar, 25)
  25.             cmd.Parameters("@username").Value = userName
  26.  
  27.  
  28.             ' Execute command and fetch pwd field into lookupPassword string.
  29.             lookupPassword = cmd.ExecuteScalar()
  30.  
  31.             ' Cleanup command and connection objects.
  32.             cmd.Dispose()
  33.             conn.Dispose()
  34.         Catch ex As Exception
  35.             ' Add error handling here for debugging.
  36.             ' This error message should not be sent back to the caller.
  37.             Label1.Text = "[ValidateUser] Exception " & ex.Message
  38.         End Try
  39.  
  40.         ' If no password found, return false.
  41.         If (lookupPassword Is Nothing) Then
  42.             ' You could write failed login attempts here to the event log for additional security.
  43.             Return False
  44.         End If
  45.  
  46.         ' Compare lookupPassword and input passWord by using a case-sensitive comparison.
  47.         Return (String.Compare(lookupPassword, passWord, False) = 0)
  48.  
  49.     End Function
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
  2.         If ValidateUser(txtUsername.Text, txtPassword.Text) Then
  3. response.redirect("")            
  4.         End If
  5.         If ValidateUser(txtUsername.Text, txtPassword.Text) = False Then
  6.             MsgBox("Username or Password incorrect, Try again.", MsgBoxStyle.Information)
  7.             txtPassword.Focus()
  8.         End If
  9.     End Sub

Or if you are running the application on your intrenet....then u can make use of VS login system and manage the roles and logins.
In your toolbox under Login you will see a control called Login....drag that onto a form and you will be given an option to Administer Website....from there you can start giving access to your website and let users create there own username and such.....just play around with those controls
Dec 2 '08 #2
Rasto
2
Do U have still problem with this?
Dec 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Simon | last post by:
Hi, I have a Login.php page that logs the user in and out. I has two forms within the page, (depending on what we are trying to do), either one to log in or out. The form calls itself using a...
2
by: adolf garlic | last post by:
I'm having a problem with a button click event being fired erroneously. My login.aspx page has the usual username/password boxes. There is also a link to click when you have filled these, plus a...
4
by: sowencheung | last post by:
Hi, all The scenario is like this: I have a master page, contains two user controls, one is a search control, another is a login control. The server-side <form> is in the master page,...
6
by: BizWorld | last post by:
Hi, I have a scenario where i need to configure only Login.aspx page to use SSL. All other application will run on HTTP protocol. If someone can guide me how to accomplish this. One of my idea...
5
by: Afshar | last post by:
Hi everybody there, I have a special Login page that wants users to enter 3 passwords rather than a single password. But can't do it with Login control. I tried following scenarios: 1. Put an...
5
by: guy | last post by:
I am not a web developer so this is probably easy! in a web app i have a login page if a user logs in, does stuff, logs out - which takes them back to the login page - how do i stop a new user...
8
by: Mitch5713 | last post by:
I've got tthree forms at start up splashscreen- works fine however how do i set the time delay so it stays on the window longer,, shows longer?? Loginscreen- works fine, after the data processing...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
3
by: Porkie999 | last post by:
-----------------------------------------------------------------------QUESTION hi i am really stuck with this and its only a small problem. i want to be able to type ......... dsfsjfjsjjfs in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.