사용자 계정 목록을 검색하려면 멤버십 데이터베이스에 어떻게 연결합니까? 예를 들어 내 프로필에 연결할 수 있습니다.MVC 회원 데이터베이스 컨텍스트?
Private db As UserProfileDbContext = New UserProfileDbContext
'
' GET: /UserProfile/
Function Index() As ViewResult
Return View(db.UserProfiles.ToList())
End Function
계정 모델에 지정된 사용자 계정 데이터베이스 컨텍스트가없는 것 같습니다. 하나를 만들거나 위와 같은 목록으로 모든 사용자 계정을 검색하는 더 좋은 방법이 있습니까?
편집 :
나는 컨트롤러에서이 코드를 가지고 :
'
' GET: /Account/ViewRegistries
Function ViewRegistries() As ViewResult
Return View(Membership.GetAllUsers().Cast(Of MembershipUser).ToList)
End Function
내보기 :
The model item passed into the dictionary is of type 'System.Collections.Generic.List
1[System.Web.Security.MembershipUser]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1[MyBlog.RegisterModel]'.
어떻게 :하지만 오류가 발생
@ModelType IEnumerable(Of MyBlog.RegisterModel)
@Code
ViewData("Title") = "Index"
End Code
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
UserId
</th>
<th>
CompanyId
</th>
<th></th>
</tr>
@For Each item In Model
Dim currentItem = item
@<tr>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.UserName)
</td>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.Company)
</td>
</tr>
Next
</table>
고쳐? 사용자를 등록하면이 데이터베이스에있는 모든 사용자의 목록을 반환합니다
Membership.GetAllUsers()
:
그냥 만들거나 로그인하여 로그인하고 거기에 등록하십시오. 사용자가 없으므로 처음에는 아무 것도 사용하지 않습니다. 만들어야합니다. – Rajesh
또한 비주얼 스튜디오에서 aspnet 구성을 사용하여 만들 수 있습니다. 또는 Visual Studio 명령 프롬프트에서 aspnet_regsql.exe를 사용할 수 있습니다. – Rajesh
@Rajesh : 서버에 게시 할 때 여전히 aspnet 구성을 사용할 수 있습니까? 암호로 보호 된 것으로 보이지 않습니다. – user1477388