我尝试了很多东西,但我总是得到“无法将字符串转换为membershipuser”
来自ASP.Net MVC Membership Starter Kit 的
来自文件ListUsers.aspx的这一行
var users = (ViewData["Users"] as List<MembershipUser>);
ViewData [“Users”]来自
public virtual ViewResult Index( int? pageIndex, int? pageSize )
{
ViewData["Title"] = "Membership Administration";
int totalRecords;
var members = Membership.GetAllUsers( pageIndex ?? 0, pageSize ?? 25, out totalRecords );
ViewData["Users"] = ToList<MembershipUser>( members );
ViewData["Roles"] = dotNetRoles.GetAllRoles().ToList();
return View( "ListUsers" );
}
谢谢!
答案 0 :(得分:7)
Dim users = TryCast(ViewData("Users"), List(Of MembershipUser))