這是我的簡單用戶名和密碼登錄,可以將用戶重定向到不同的「會員區」頁面。爲什麼我得到:'System.Collections.IEnumerable'沒有類型參數,因此不能有類型參數?
不過,我得到一個:
BC32045:「System.Collections.IEnumerable」沒有類型參數,所以不能有類型參數
而且我不知道爲什麼。
任何人都可以幫忙嗎?
謝謝大衛。
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
你從哪裏得到它? –
@TimSchmelter在這一行:Private ReadOnly _credentials由於IEnumerable(Of Cred)= New(){New Cred(「userone」,「passwordone」),New Cred(「usertwo」,「passwordtwo」),New Cred(「userthree 「,」passwordthree「,」/admin/custom.aspx「)} –
您可能導入System.Collections而不是System.Collections.Generic某處。 –