Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class MyPage
- Inherits Page
- Private Structure Cred
- Public Username As String
- Public Password As String
- Public RedirectUrl As String
- Public Sub New(un As String, pw As String, Optional ru As String = "/admin/default.aspx")
- Username = un
- Password = pw
- RedirectUrl = ru
- End Sub
- End Structure
- Private ReadOnly _credentials As IEnumerable(Of Cred) = New () {New Cred("userone", "passwordone"), New Cred("usertwo", "passwordtwo"), New Cred("userthree", "passwordthree", "/admin/custom.aspx")}
- Public Sub Page_Load(sender As Object, e As EventArgs)
- Dim user = _credentials.SingleOrDefault(Function(x) x.Username = UserName.Text AndAlso x.Password = Password.Text)
- If user IsNot Nothing Then
- Session("Admin") = True
- Response.Redirect(user.RedirectUrl)
- Else
- Session("Admin") = False
- LtlLogin.Text = "<p>Sorry, you have provided incorrect login details.</p>"
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement